aboutsummaryrefslogtreecommitdiffstats
path: root/emulator
diff options
context:
space:
mode:
authorJack Veenstra <veenstra@android.com>2009-05-09 11:44:53 -0700
committerJack Veenstra <veenstra@android.com>2009-05-09 11:44:53 -0700
commit59d89a2bf1c867878985ea7b48e6474ce1865e4a (patch)
tree8b04964f40fe2b738c15008ac53002d7f06036c4 /emulator
parentdbd3cafbb4056aa36f5c157aca75f15b248ebba4 (diff)
downloadsdk-59d89a2bf1c867878985ea7b48e6474ce1865e4a.zip
sdk-59d89a2bf1c867878985ea7b48e6474ce1865e4a.tar.gz
sdk-59d89a2bf1c867878985ea7b48e6474ce1865e4a.tar.bz2
Add a "-d time" option to stack_dump to dump the stack at the given time.
Diffstat (limited to 'emulator')
-rw-r--r--emulator/qtools/stack_dump.cpp39
1 files changed, 34 insertions, 5 deletions
diff --git a/emulator/qtools/stack_dump.cpp b/emulator/qtools/stack_dump.cpp
index b5014ef..35ee61c 100644
--- a/emulator/qtools/stack_dump.cpp
+++ b/emulator/qtools/stack_dump.cpp
@@ -15,6 +15,9 @@ typedef TraceReader<> TraceReaderType;
#include "parse_options-inl.h"
#include "callstack.h"
+static uint64_t debugTime;
+static uint64_t dumpTime = 0;
+
class MyFrame : public StackFrame<symbol_type> {
public:
void push(int stackLevel, uint64_t time, CallStackBase *base);
@@ -25,6 +28,8 @@ typedef CallStack<MyFrame> CallStackType;
void MyFrame::push(int stackLevel, uint64_t time, CallStackBase *base)
{
+ if (dumpTime > 0)
+ return;
printf("%llu en thr %d %3d", time, base->getId(), stackLevel);
for (int ii = 0; ii < stackLevel; ++ii)
printf(".");
@@ -33,6 +38,8 @@ void MyFrame::push(int stackLevel, uint64_t time, CallStackBase *base)
void MyFrame::pop(int stackLevel, uint64_t time, CallStackBase *base)
{
+ if (dumpTime > 0)
+ return;
printf("%llu x thr %d %3d", time, base->getId(), stackLevel);
for (int ii = 0; ii < stackLevel; ++ii)
printf(".");
@@ -43,8 +50,6 @@ static const int kNumStackFrames = 500;
static const int kMaxThreads = (32 * 1024);
CallStackType *stacks[kMaxThreads];
-static uint64_t debugTime;
-
void Usage(const char *program)
{
fprintf(stderr, "Usage: %s [options] trace_name elf_file\n",
@@ -52,9 +57,29 @@ void Usage(const char *program)
OptionsUsage();
}
+bool localParseOptions(int argc, char **argv)
+{
+ bool err = false;
+ while (!err) {
+ int opt = getopt(argc, argv, "+d:");
+ if (opt == -1)
+ break;
+ switch (opt) {
+ case 'd':
+ dumpTime = strtoull(optarg, NULL, 0);
+ break;
+ default:
+ err = true;
+ break;
+ }
+ }
+ return err;
+}
+
int main(int argc, char **argv)
{
ParseOptions(argc, argv);
+ localParseOptions(argc, argv);
if (argc - optind != 2) {
Usage(argv[0]);
exit(1);
@@ -66,9 +91,6 @@ int main(int argc, char **argv)
trace->Open(qemu_trace_file);
trace->ReadKernelSymbols(elf_file);
trace->SetRoot(root);
- TraceHeader *qheader = trace->GetHeader();
- uint64_t startTime = qheader->start_sec;
- startTime = (startTime << 32) | qheader->start_usec;
BBEvent event;
while (1) {
@@ -93,6 +115,13 @@ int main(int argc, char **argv)
// Update the stack
pStack->updateStack(&event, function);
+
+ // If the user requested a stack dump at a certain time,
+ // and we are at that time, then dump the stack and exit.
+ if (dumpTime > 0 && event.time >= dumpTime) {
+ pStack->showStack(stdout);
+ break;
+ }
}
for (int ii = 0; ii < kMaxThreads; ++ii) {