[PATCH] Add Guile frame unwinder interface
Andy Wingo
wingo@igalia.com
Thu Mar 5 15:58:00 GMT 2015
Hi,
This is an implementation of a frame unwinder interface in the spirit of
Alexander's work in this thread:
http://thread.gmane.org/gmane.comp.gdb.patches/103360/focus=105202
No documentation yet, and I am still wondering how to test it
appropriately. However it does seem some feedback could be useful
before I document the wrong thing; particualarly I would like feedback
on the changes to frame-unwind.c and frame.c.
However happily it does work in V8; eliding some helpers, the
implementation looks like this:
(use-modules (gdb frame-unwinders))
(define (unwind-v8-frame frame)
(let ((isolate (cached-current-isolate)))
(when isolate
(let* ((this-pc (ephemeral-frame-read-register frame "rip"))
(this-fp (ephemeral-frame-read-register frame "rbp"))
(code (lookup-code-for-pc this-pc isolate)))
(when code
(set-ephemeral-frame-id! frame this-fp (code-instruction-start code))
(let* ((type (if (code-optimized? code) 'javascript 'optimized))
(prev-pc-address (compute-standard-frame-pc-address this-fp))
(prev-sp (compute-frame-older-sp this-fp type))
(prev-fp (compute-standard-frame-older-fp this-fp))
(prev-pc (value-dereference prev-pc-address)))
(ephemeral-frame-add-saved-register! frame "rsp" prev-sp)
(ephemeral-frame-add-saved-register! frame "rbp" prev-fp)
(ephemeral-frame-add-saved-register! frame "rip" prev-pc)))))))
(define* (install-frame-unwinders #:optional (objfile (current-objfile)))
(add-frame-unwinder!
(make-frame-unwinder "guile-v8-frame-unwinder" unwind-v8-frame)))
And most happily, it requires no changes in V8 itself. Yaaay :) With
an appropriate frame filter, a backtrace looks like this:
#0 0x00000d3c5b0661a1 in TestCase () at /hack/v8/test/mjsunit/debug-step-4-in-frame.js:94
#1 0x00000d3c5b06a3d3 in () at /hack/v8/test/mjsunit/debug-step-4-in-frame.js:112
#2 0x00000d3c5b02c620 in [internal frame] ()
#3 0x00000d3c5b014d31 in [entry frame] ()
#4 0x0000000000b4e949 in v8::internal::Invoke([...]) at ../src/execution.cc:128
#5 0x0000000000b4ed23 in v8::internal::Execution::Call([...]) at ../src/execution.cc:179
#6 0x0000000000a3f813 in v8::Script::Run([...]) at ../src/api.cc:1514
#7 0x0000000000a149fa in v8::Shell::ExecuteString([...]) at ../src/d8.cc:281
#8 0x0000000000a194eb in v8::SourceGroup::Execute([...]) at ../src/d8.cc:1213
#9 0x0000000000a1a128 in v8::Shell::RunMain([...]) at ../src/d8.cc:1448
#10 0x0000000000a1efdc in v8::Shell::Main([...]) at ../src/d8.cc:1721
#11 0x0000000000a1f143 in main([...]) at ../src/d8.cc:1757
instead of this:
#0 0x00000d3c5b0661a1 in ?? ()
#1 0x0000000002404940 in ?? ()
#2 0x0000219b8fc5d779 in ?? ()
#3 0x000018a8ddbf01d9 in ?? ()
#4 0x0000219b8fc62a81 in ?? ()
#5 0x000018a8ddbf0179 in ?? ()
#6 0x00007fffffffd500 in ?? ()
#7 0x00000d3c5b06a3d3 in ?? ()
#8 0x00001df7db238fb1 in ?? ()
#9 0x0000000000000000 in ?? ()
Yaaaaaaaaaaay :)
Regards,
Andy
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0001-Add-Guile-frame-unwinder-interface.patch
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20150305/68bc10a5/attachment.ksh>
More information about the Gdb-patches
mailing list