mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:49:47 +00:00
[vm] Provide a couple more gdb helpers to print stack traces.
Use with caution. Change-Id: Ic2a3055ede694406596596d57ba54909a6985cde Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116080 Commit-Queue: Régis Crelier <regis@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
d7c96f323d
commit
6f4ceb887e
|
@ -3,6 +3,7 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
#include "lib/stacktrace.h"
|
||||
#include "vm/heap/safepoint.h"
|
||||
#include "vm/object.h"
|
||||
#include "vm/stack_frame.h"
|
||||
|
||||
|
@ -39,12 +40,48 @@ void _printStackTrace() {
|
|||
Thread::Current(),
|
||||
StackFrameIterator::kNoCrossThreadIteration);
|
||||
StackFrame* frame = frames.NextFrame();
|
||||
while (frame != NULL) {
|
||||
while (frame != nullptr) {
|
||||
OS::PrintErr("%s\n", frame->ToCString());
|
||||
frame = frames.NextFrame();
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(TARGET_ARCH_DBC)
|
||||
// Like _printDartStackTrace, but works when stopped in generated code.
|
||||
// Must be called with the current fp, sp, and pc.
|
||||
DART_EXPORT
|
||||
void _printGeneratedStackTrace(uword fp, uword sp, uword pc) {
|
||||
StackFrameIterator frames(fp, sp, pc, ValidationPolicy::kDontValidateFrames,
|
||||
Thread::Current(),
|
||||
StackFrameIterator::kNoCrossThreadIteration);
|
||||
StackFrame* frame = frames.NextFrame();
|
||||
while (frame != nullptr) {
|
||||
OS::PrintErr("%s\n", frame->ToCString());
|
||||
frame = frames.NextFrame();
|
||||
}
|
||||
}
|
||||
|
||||
// Like _printDartStackTrace, but works in the interpreter loop.
|
||||
// Must be called with the current interpreter fp, sp, and pc.
|
||||
// Note that sp[0] is not modified, but sp[1] will be trashed.
|
||||
DART_EXPORT
|
||||
void _printInterpreterStackTrace(RawObject** fp,
|
||||
RawObject** sp,
|
||||
const KBCInstr* pc) {
|
||||
Thread* thread = Thread::Current();
|
||||
sp[1] = Function::null();
|
||||
sp[2] = Bytecode::null();
|
||||
sp[3] = reinterpret_cast<RawObject*>(reinterpret_cast<uword>(pc));
|
||||
sp[4] = reinterpret_cast<RawObject*>(fp);
|
||||
RawObject** exit_fp = sp + 1 + kKBCDartFrameFixedSize;
|
||||
thread->set_top_exit_frame_info(reinterpret_cast<uword>(exit_fp));
|
||||
thread->set_execution_state(Thread::kThreadInVM);
|
||||
_printDartStackTrace();
|
||||
thread->set_execution_state(Thread::kThreadInGenerated);
|
||||
thread->set_top_exit_frame_info(0);
|
||||
}
|
||||
#endif // !defined(TARGET_ARCH_DBC)
|
||||
|
||||
class PrintObjectPointersVisitor : public ObjectPointerVisitor {
|
||||
public:
|
||||
PrintObjectPointersVisitor() : ObjectPointerVisitor(Isolate::Current()) {}
|
||||
|
@ -64,7 +101,7 @@ void _printStackTraceWithLocals() {
|
|||
Thread::Current(),
|
||||
StackFrameIterator::kNoCrossThreadIteration);
|
||||
StackFrame* frame = frames.NextFrame();
|
||||
while (frame != NULL) {
|
||||
while (frame != nullptr) {
|
||||
OS::PrintErr("%s\n", frame->ToCString());
|
||||
frame->VisitObjectPointers(&visitor);
|
||||
frame = frames.NextFrame();
|
||||
|
|
Loading…
Reference in a new issue