Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redebug #1583

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open

Redebug #1583

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
4bb2e2d
translate: rearrange
Bike Apr 23, 2024
35ef606
Destroy old compiler debug info mechanism
Bike Apr 23, 2024
6fe8690
define lambda lists for DIBuilder extern defmethods
Bike Apr 24, 2024
4b4df0a
Start on new debug info system
Bike Apr 29, 2024
ef36513
Disable inlining & enable new DWARF generation
Bike Apr 30, 2024
eca6338
integrate arguments processing code into clasp-cleavir more
Bike Apr 30, 2024
24d8feb
arguments processor can use LOOP now
Bike Apr 30, 2024
6a4a437
Delete unused calling convention slot
Bike Apr 30, 2024
3326d48
Allow wrong-number-of-arguments to have just a function's name
Bike Apr 30, 2024
cb6ed18
Move register-save-area handling into translate
Bike May 1, 2024
4571a70
Make the argument processor for-effect
Bike May 1, 2024
1af73df
reorient optional argument processor to not compute nremaining
Bike May 1, 2024
a365f50
Integrate argument processing into clasp-cleavir
Bike May 2, 2024
d30902f
have argument parser return arguments instead of side effecting
Bike May 2, 2024
6fb6158
Have argument processor handle casting
Bike May 4, 2024
6bc98e2
No more separate argument processing for local calls
Bike May 5, 2024
013faca
Add return-type to mangled wrapper names
yitzchak May 5, 2024
41c8c91
Use LLVM's poison instead of undef in most places
Bike May 5, 2024
2f9ed4f
Make backtraces a little better at optimized code
Bike May 8, 2024
d28a1e4
Delete unused code
Bike May 8, 2024
8ef8e97
Move LLVM optimization outside of with-module macro
Bike May 9, 2024
f36d8b6
Make arguments available in optimized function backtraces
Bike May 9, 2024
8f4d012
Actually use LLVM optimizations
Bike May 10, 2024
5fd7f04
Delete inline AST re-sourcing code
Bike May 10, 2024
97617d0
new debuginfo: handle functions with different source files
Bike May 10, 2024
9d37198
Make defaultEntryAddress/arityEntryAddress functions non virtual
Bike May 10, 2024
d3b1ff4
Update Cleavir
Bike May 13, 2024
2a081e7
clasp-cleavir: allow non-object rtypes in come-from
Bike May 13, 2024
64fa5e1
Fix SPI lineno extraction
Bike May 15, 2024
889f73b
Handle logical pathnames in debug info at lower level
Bike May 15, 2024
9a6247f
Use ensure-difile uniformly
Bike May 15, 2024
119fe7e
Remove unused parameters
Bike May 15, 2024
6bce0d9
Restore install path debug info for reproducible builds, hopefully
Bike May 15, 2024
5b40490
Output DWARF info for local variables
Bike May 16, 2024
9d9e41e
Clean up unused code for source pos infos
Bike May 17, 2024
ad39129
Define direct pathname reader for SPIs
Bike May 17, 2024
abd44ac
More source pos info cleanup
Bike May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Output DWARF info for local variables
Nothing seems to be showing up, though. Very weird.
  • Loading branch information
Bike committed May 16, 2024
commit 5b40490963a573efd735f24f87af848a67cdf73d
30 changes: 30 additions & 0 deletions src/lisp/kernel/cleavir/debuginfo.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,36 @@
(llvm-sys:get-dilocation (cmp:thread-local-llvm-context)
lineno column *dbg-current-scope*)))

;;; Generate debug info for a variable binding.
(defun di-bind-variable (name alloca spi vrtype)
(when spi
(multiple-value-bind (path line) (spi-info spi)
(let* ((type (vrtype->di vrtype))
(var
(llvm-sys:create-auto-variable
*dibuilder* *dbg-current-scope* name
(ensure-difile path) line type nil (di-zeroflags) 0))
(expr
(llvm-sys:create-expression-none *dibuilder*)))
(llvm-sys:dibuilder/insert-declare
*dibuilder* alloca var expr (get-dilocation spi)
(llvm-sys:get-insert-block cmp:*irbuilder*))))))

;;; Generate debug info for an SSA variable binding.
(defun di-bind-value (name value spi vrtype)
(when spi
(multiple-value-bind (path line) (spi-info spi)
(let* ((type (vrtype->di vrtype))
(var
(llvm-sys:create-auto-variable
*dibuilder* *dbg-current-scope* name
(ensure-difile path) line type nil (di-zeroflags) 0))
(expr
(llvm-sys:create-expression-none *dibuilder*)))
(llvm-sys:dibuilder/insert-dbg-value-intrinsic
*dibuilder* value var expr (get-dilocation spi)
(llvm-sys:get-insert-block cmp:*irbuilder*))))))

;;; if SPI is nil we unset the debug location.
(defun set-instruction-source-position (spi)
(when *generate-dwarf*
Expand Down
21 changes: 9 additions & 12 deletions src/lisp/kernel/cleavir/translation-environment.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
;;; a little bit more complete.
(defun full-datum-name-as-string (datum)
(let ((*package* (find-package "KEYWORD")))
(write-to-string datum :escape t :readably nil :pretty nil)))
(write-to-string (bir:name datum)
:escape t :readably nil :pretty nil)))

(defgeneric vrtype->llvm (vrtype))
(defmethod vrtype->llvm ((vrtype (eql :object))) cmp:%t*%)
Expand All @@ -79,7 +80,6 @@
((:local :dynamic)
;; just an alloca
(let* ((name (datum-name-as-string var))
#+(or)
(fname (full-datum-name-as-string var))
(rtype (cc-bmir:rtype var)))
(if (null rtype)
Expand All @@ -91,12 +91,8 @@
(first (cc-bmir:rtype var)))
(t (error "BUG: Bad rtype ~a" rtype))))
(alloca (cmp:alloca (vrtype->llvm vrtype) 1 name))
#+(or)
(spi (origin-spi (bir:origin var))))
;; set up debug info
;; Disable for now - FIXME and get it working
#+(or)(cmp:dbg-variable-alloca alloca fname spi)
;; return
(spi (origin-spi (origin-source (bir:origin var)))))
(di-bind-variable fname alloca spi vrtype)
alloca))))
((:indefinite)
;; make a cell
Expand Down Expand Up @@ -204,10 +200,11 @@
(check-type variable bir:variable)
(if (bir:immutablep variable)
(prog1 (setf (gethash variable *datum-values*) value)
;; FIXME - this doesn't work yet
#+(or)(cmp:dbg-variable-value
value (full-datum-name-as-string variable)
(origin-spi (bir:origin variable))))
(let ((rtype (cc-bmir:rtype variable)))
(unless (null rtype)
(di-bind-value (full-datum-name-as-string variable)
value (origin-spi (origin-source (bir:origin variable)))
(first rtype)))))
(if (null (cc-bmir:rtype variable))
value
;; NOTE: For typed loads in the future, use the rtype
Expand Down
41 changes: 35 additions & 6 deletions src/llvmo/debugInfoExpose.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,42 @@ CL_LAMBDA(dibuilder scope name argno file lineno type always-preserve-p flags an
CL_LISPIFY_NAME(createParameterVariable);
CL_EXTERN_DEFMETHOD(DIBuilder_O, &llvm::DIBuilder::createParameterVariable);

// We don't expose the instruction version since we don't really need it.
// We want to use these instead of manually inserting an intrinsic
// call so that when LLVM transitions to debug info records we
// don't have to do anything.
// (Despite the name, insertDbgValueIntrinsic can insert the new
// records rather than an intrinsic.)
// We don't expose the insert-before-instruction versions as we
// do not need them.
// FIXME: Function instead of a method because we don't really
// care about the DbgInstPtr return value and exposing it would
// be rather complex.
CL_LAMBDA(dibuilder val varinfo expr dilocation basic-block);
CL_LISPIFY_NAME(insertDbgValueIntrinsic);
CL_EXTERN_DEFMETHOD(DIBuilder_O, (llvm::Instruction * (llvm::DIBuilder::*)(llvm::Value * Val, llvm::DILocalVariable* VarInfo,
llvm::DIExpression* Expr, const llvm::DILocation* DL,
llvm::BasicBlock* InsertAtEnd)) &
llvm::DIBuilder::insertDbgValueIntrinsic);
CL_LISPIFY_NAME(dibuilder/insertDbgValueIntrinsic);
CL_DEFUN void llvm_sys__insert_dbg_value(llvm::DIBuilder& DIBuilder,
llvm::Value* V,
llvm::DILocalVariable* VarInfo,
llvm::DIExpression* Expr,
DILocation_sp DL,
llvm::BasicBlock* InsertAtEnd)
{
// FIXME: why not just use from_object?
// This is cargo-culted from IRBuilderBase_O::SetCurrentDebugLocation
llvm::DILocation* real_diloc = DL->operator llvm::DILocation*();
DIBuilder.insertDbgValueIntrinsic(V, VarInfo, Expr, real_diloc, InsertAtEnd);
}
CL_LAMBDA(dibuilder val varinfo expr dilocation basic-block);
CL_LISPIFY_NAME(dibuilder/insertDeclare);
CL_DEFUN void llvm_sys__insert_declare(llvm::DIBuilder& DIBuilder,
llvm::Value* Storage,
llvm::DILocalVariable* VarInfo,
llvm::DIExpression* Expr,
DILocation_sp DL,
llvm::BasicBlock* InsertAtEnd)
{
llvm::DILocation* real_diloc = DL->operator llvm::DILocation*();
DIBuilder.insertDeclare(Storage, VarInfo, Expr, real_diloc, InsertAtEnd);
}

CL_LAMBDA(dibuilder);
CL_LISPIFY_NAME(finalize);
Expand Down
Loading