diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-05-20 09:21:20 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-05-20 09:21:20 -0700 |
commit | 0367b1515d8e0d101297f3622e41308645e48dbe (patch) | |
tree | 9dffaeac73d1cc32af7d0aa11a22856944b85a34 /emulator/qtools | |
parent | faba7ee37b15cd01594c6cd7ab2ff54651da3593 (diff) | |
parent | 9d71bce5f5cd62d6e8dd491334a4f307147741a3 (diff) | |
download | sdk-0367b1515d8e0d101297f3622e41308645e48dbe.zip sdk-0367b1515d8e0d101297f3622e41308645e48dbe.tar.gz sdk-0367b1515d8e0d101297f3622e41308645e48dbe.tar.bz2 |
am d7dc91d7: Merge change 2030 into donut
Merge commit 'd7dc91d749b920734c9e9f0a21c7c7e9672ef8b6'
* commit 'd7dc91d749b920734c9e9f0a21c7c7e9672ef8b6':
Add new trace tool for displaying all the memory regions in a process.
Diffstat (limited to 'emulator/qtools')
-rw-r--r-- | emulator/qtools/Android.mk | 8 | ||||
-rw-r--r-- | emulator/qtools/dump_regions.cpp | 59 |
2 files changed, 67 insertions, 0 deletions
diff --git a/emulator/qtools/Android.mk b/emulator/qtools/Android.mk index 53e5e36..149390c 100644 --- a/emulator/qtools/Android.mk +++ b/emulator/qtools/Android.mk @@ -147,3 +147,11 @@ LOCAL_C_INCLUDES += $(common_includes) LOCAL_CFLAGS += $(common_cflags) LOCAL_MODULE := profile_pid include $(BUILD_HOST_EXECUTABLE) + +include $(CLEAR_VARS) +LOCAL_SRC_FILES := dump_regions.cpp trace_reader.cpp decoder.cpp \ + read_elf.cpp parse_options.cpp +LOCAL_C_INCLUDES += $(common_includes) +LOCAL_CFLAGS += $(common_cflags) +LOCAL_MODULE := dump_regions +include $(BUILD_HOST_EXECUTABLE) diff --git a/emulator/qtools/dump_regions.cpp b/emulator/qtools/dump_regions.cpp new file mode 100644 index 0000000..57389f9 --- /dev/null +++ b/emulator/qtools/dump_regions.cpp @@ -0,0 +1,59 @@ +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <inttypes.h> +#include <string.h> +#include "trace_reader.h" +#include "parse_options.h" + +typedef TraceReader<> TraceReaderType; + +#include "parse_options-inl.h" + +void Usage(const char *program) +{ + fprintf(stderr, "Usage: %s [options] trace_file\n", program); + OptionsUsage(); +} + +int main(int argc, char **argv) { + // Parse the options + ParseOptions(argc, argv); + if (argc - optind != 1) { + Usage(argv[0]); + exit(1); + } + + char *trace_filename = argv[optind]; + TraceReader<> *trace = new TraceReader<>; + trace->Open(trace_filename); + trace->SetRoot(root); + + while (1) { + BBEvent event, ignored; + symbol_type *dummy_sym; + + if (GetNextValidEvent(trace, &event, &ignored, &dummy_sym)) + break; + } + + int num_procs; + ProcessState *processes = trace->GetProcesses(&num_procs); + + ProcessState *pstate = &processes[0]; + for (int ii = 0; ii < num_procs; ++ii, ++pstate) { + if (pstate->name == NULL) + pstate->name = ""; + ProcessState *manager = pstate->addr_manager; + printf("pid %d regions: %d %s", + pstate->pid, manager->nregions, pstate->name); + for (int jj = 1; jj < pstate->argc; ++jj) { + printf(" %s", pstate->argv[jj]); + } + printf("\n"); + trace->DumpRegions(stdout, pstate); + } + + delete trace; + return 0; +} |