aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/qtools
diff options
context:
space:
mode:
authorJack Veenstra <veenstra@android.com>2009-05-19 17:37:00 -0700
committerJack Veenstra <veenstra@android.com>2009-05-19 17:37:00 -0700
commita42e6fb33ae92d591336825a2c8274c2ba5cd02b (patch)
tree72641575406eaff91982b51a5d7d081fcdef32e5 /emulator/qtools
parentc627baa5fe13370895cb36cbff1300bad8bc96de (diff)
downloadsdk-a42e6fb33ae92d591336825a2c8274c2ba5cd02b.zip
sdk-a42e6fb33ae92d591336825a2c8274c2ba5cd02b.tar.gz
sdk-a42e6fb33ae92d591336825a2c8274c2ba5cd02b.tar.bz2
Add new trace tool for displaying all the memory regions in a process.
Diffstat (limited to 'emulator/qtools')
-rw-r--r--emulator/qtools/Android.mk8
-rw-r--r--emulator/qtools/dump_regions.cpp59
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;
+}