diff options
-rw-r--r-- | emulator/qtools/coverage.cpp | 2 | ||||
-rw-r--r-- | emulator/qtools/post_trace.cpp | 2 | ||||
-rw-r--r-- | emulator/qtools/profile_pid.cpp | 2 | ||||
-rw-r--r-- | emulator/qtools/profile_trace.cpp | 2 | ||||
-rw-r--r-- | emulator/qtools/q2dm.cpp | 3 | ||||
-rw-r--r-- | emulator/qtools/read_addr.cpp | 2 | ||||
-rw-r--r-- | emulator/qtools/trace_reader.cpp | 20 | ||||
-rw-r--r-- | emulator/qtools/trace_reader.h | 19 | ||||
-rw-r--r-- | emulator/qtools/trace_reader_base.h | 20 |
9 files changed, 36 insertions, 36 deletions
diff --git a/emulator/qtools/coverage.cpp b/emulator/qtools/coverage.cpp index fb1fe52..790f721 100644 --- a/emulator/qtools/coverage.cpp +++ b/emulator/qtools/coverage.cpp @@ -137,7 +137,7 @@ int main(int argc, char **argv) continue; if (strcmp(psym->name, ".plt") == 0) continue; - char *ksym = " "; + const char *ksym = " "; if (psym->region->flags & region_type::kIsKernelRegion) ksym = "k"; printf("%s %s %s\n", ksym, psym->name, psym->region->path); diff --git a/emulator/qtools/post_trace.cpp b/emulator/qtools/post_trace.cpp index 99525fb..becfc2b 100644 --- a/emulator/qtools/post_trace.cpp +++ b/emulator/qtools/post_trace.cpp @@ -137,7 +137,7 @@ int main(int argc, char **argv) { double insn_per_sec = 0; if (elapsed_secs != 0) insn_per_sec = num_dynamic_insn / elapsed_secs; - char *suffix = ""; + const char *suffix = ""; if (insn_per_sec >= 1000000) { insn_per_sec /= 1000000.0; suffix = "M"; diff --git a/emulator/qtools/profile_pid.cpp b/emulator/qtools/profile_pid.cpp index aa37847..589abe9 100644 --- a/emulator/qtools/profile_pid.cpp +++ b/emulator/qtools/profile_pid.cpp @@ -76,7 +76,7 @@ int main(int argc, char **argv) { sum_time += pstate->cpu_time; double per = 100.0 * pstate->cpu_time / total_time; double sum_per = 100.0 * sum_time / total_time; - char *print_flags = ""; + const char *print_flags = ""; if ((pstate->flags & ProcessState::kCalledExec) == 0) print_flags = "T"; if (pstate->name == NULL) diff --git a/emulator/qtools/profile_trace.cpp b/emulator/qtools/profile_trace.cpp index 9d14a03..0b056cc 100644 --- a/emulator/qtools/profile_trace.cpp +++ b/emulator/qtools/profile_trace.cpp @@ -118,7 +118,7 @@ int main(int argc, char **argv) double per = 100.0 * sym->elapsed / total; double sum_per = 100.0 * sum / total; double secs = 1.0 * sym->elapsed / kMHz; - char *ksym = " "; + const char *ksym = " "; if (sym->region->flags & region_type::kIsKernelRegion) ksym = "k"; printf("%12.2f %11lld %6.2f %6.2f %s %s\n", diff --git a/emulator/qtools/q2dm.cpp b/emulator/qtools/q2dm.cpp index 7f987dc..74dbaeb 100644 --- a/emulator/qtools/q2dm.cpp +++ b/emulator/qtools/q2dm.cpp @@ -208,7 +208,7 @@ int main(int argc, char **argv) if (pStack == NULL) { pStack = new CallStackType(event.pid, kNumStackFrames, trace); stacks[event.pid] = pStack; - char *name = trace->GetProcessName(event.pid); + const char *name = trace->GetProcessName(event.pid); dmtrace->addThread(event.pid, name); } @@ -267,7 +267,6 @@ int main(int argc, char **argv) } } - dmtrace->close(); delete dmtrace; delete trace; diff --git a/emulator/qtools/read_addr.cpp b/emulator/qtools/read_addr.cpp index 38fc62a..1c8c20f 100644 --- a/emulator/qtools/read_addr.cpp +++ b/emulator/qtools/read_addr.cpp @@ -20,7 +20,7 @@ int main(int argc, char **argv) { if (trace->ReadAddr(&time, &addr, &flags)) break; - char *op = "ld"; + const char *op = "ld"; if (flags == 1) op = "st"; printf("%lld 0x%08x %s\n", time, addr, op); diff --git a/emulator/qtools/trace_reader.cpp b/emulator/qtools/trace_reader.cpp index b38c0b4..d2af64f 100644 --- a/emulator/qtools/trace_reader.cpp +++ b/emulator/qtools/trace_reader.cpp @@ -131,7 +131,7 @@ BBReader::~BBReader() delete decoder_; } -void BBReader::Open(char *filename) +void BBReader::Open(const char *filename) { // Initialize the class variables memset(&nextrec_, 0, sizeof(TimeRec)); @@ -268,7 +268,7 @@ InsnReader::~InsnReader() delete decoder_; } -void InsnReader::Open(char *filename) +void InsnReader::Open(const char *filename) { prev_time_ = 0; time_diff_ = 0; @@ -310,7 +310,7 @@ AddrReader::~AddrReader() } // Returns true if there is an error opening the file -bool AddrReader::Open(char *filename, char *suffix) +bool AddrReader::Open(const char *filename, const char *suffix) { struct stat stat_buf; @@ -367,7 +367,7 @@ ExcReader::~ExcReader() delete decoder_; } -void ExcReader::Open(char *filename) +void ExcReader::Open(const char *filename) { prev_time_ = 0; prev_recnum_ = 0; @@ -421,7 +421,7 @@ PidReader::~PidReader() delete decoder_; } -void PidReader::Open(char *filename) +void PidReader::Open(const char *filename) { prev_time_ = 0; @@ -561,7 +561,7 @@ MethodReader::~MethodReader() delete decoder_; } -bool MethodReader::Open(char *filename) +bool MethodReader::Open(const char *filename) { struct stat stat_buf; @@ -686,8 +686,8 @@ TraceReaderBase::~TraceReaderBase() delete[] static_filename_; } -void TraceReaderBase::ReadTraceHeader(FILE *fstream, char *filename, - char *tracename, TraceHeader *header) +void TraceReaderBase::ReadTraceHeader(FILE *fstream, const char *filename, + const char *tracename, TraceHeader *header) { int rval = fread(header, sizeof(TraceHeader), 1, fstream); if (rval != 1) { @@ -721,7 +721,7 @@ void TraceReaderBase::ReadTraceHeader(FILE *fstream, char *filename, } -void TraceReaderBase::Open(char *filename) +void TraceReaderBase::Open(const char *filename) { char *fname; FILE *fstream; @@ -840,7 +840,7 @@ static void CopyDexSymbolsToArray(DexFileList *dexfile, } } -void TraceReaderBase::ParseDexList(char *filename) +void TraceReaderBase::ParseDexList(const char *filename) { struct stat stat_buf; static const int kBufSize = 4096; diff --git a/emulator/qtools/trace_reader.h b/emulator/qtools/trace_reader.h index 4123014..f73f17a 100644 --- a/emulator/qtools/trace_reader.h +++ b/emulator/qtools/trace_reader.h @@ -165,7 +165,7 @@ class TraceReader : public TraceReaderBase { uint32_t flags; int argc; char **argv; - char *name; + const char *name; int nregions; // num regions in use int max_regions; // max regions allocated region_type **regions; @@ -189,7 +189,7 @@ class TraceReader : public TraceReaderBase { ProcessState *GetCurrentProcess() { return current_; } ProcessState *GetProcesses(int *num_procs); ProcessState *GetNextProcess(); - char *GetProcessName(int pid); + const char *GetProcessName(int pid); void SetRoot(const char *root) { root_ = root; } void SetDemangle(bool demangle) { demangle_ = demangle; } bool ReadMethodSymbol(MethodRec *method_record, @@ -276,11 +276,14 @@ TraceReader<T>::~TraceReader() hash_entry_type *ptr; for (ptr = hash_->GetFirst(); ptr; ptr = hash_->GetNext()) { region_type *region = ptr->value; - int nsymbols = region->nsymbols; - for (int ii = 0; ii < nsymbols; ii++) { - delete[] region->symbols[ii].name; + // If the symbols are not shared with another region, then delete them. + if ((region->flags & region_type::kSharedSymbols) == 0) { + int nsymbols = region->nsymbols; + for (int ii = 0; ii < nsymbols; ii++) { + delete[] region->symbols[ii].name; + } + delete[] region->symbols; } - delete[] region->symbols; delete[] region->path; // Do not delete the region itself here. Each region @@ -422,7 +425,7 @@ TraceReader<T>::GetNextProcess() } template<class T> -char* TraceReader<T>::GetProcessName(int pid) +const char* TraceReader<T>::GetProcessName(int pid) { if (pid < 0 || pid >= kNumPids || processes_[pid] == NULL) return "(unknown)"; @@ -1165,8 +1168,6 @@ void TraceReader<T>::HandlePidEvent(PidEvent *event) } else { region->nsymbols = existing_region->nsymbols; region->symbols = existing_region->symbols; - region->path = existing_region->path; - delete[] event->path; region->flags |= region_type::kSharedSymbols; } diff --git a/emulator/qtools/trace_reader_base.h b/emulator/qtools/trace_reader_base.h index 281d085..416c3d1 100644 --- a/emulator/qtools/trace_reader_base.h +++ b/emulator/qtools/trace_reader_base.h @@ -83,7 +83,7 @@ class TraceReaderBase { friend class BBReader; - void Open(char *filename); + void Open(const char *filename); void Close(); void WriteHeader(TraceHeader *header); inline bool ReadBB(BBEvent *event); @@ -120,10 +120,10 @@ class TraceReaderBase { private: int FindNumInsns(uint64_t bb_num, uint64_t bb_start_time); - void ReadTraceHeader(FILE *fstream, char *filename, - char *tracename, TraceHeader *header); + void ReadTraceHeader(FILE *fstream, const char *filename, + const char *tracename, TraceHeader *header); PidEvent *FindMmapDexFileEvent(); - void ParseDexList(char *filename); + void ParseDexList(const char *filename); char *static_filename_; FILE *static_fstream_; @@ -159,7 +159,7 @@ class BBReader { public: explicit BBReader(TraceReaderBase *trace); ~BBReader(); - void Open(char *filename); + void Open(const char *filename); void Close(); bool ReadBB(BBEvent *event); @@ -193,7 +193,7 @@ class InsnReader { InsnReader(); ~InsnReader(); - void Open(char *filename); + void Open(const char *filename); void Close(); uint64_t ReadInsnTime(uint64_t min_time); @@ -209,7 +209,7 @@ class AddrReader { AddrReader(); ~AddrReader(); - bool Open(char *filename, char *suffix); + bool Open(const char *filename, const char *suffix); void Close(); bool ReadAddr(uint64_t *time, uint32_t *addr); @@ -225,7 +225,7 @@ class ExcReader { ExcReader(); ~ExcReader(); - void Open(char *filename); + void Open(const char *filename); void Close(); bool ReadExc(uint64_t *time, uint32_t *current_pc, uint64_t *recnum, uint32_t *target_pc, @@ -243,7 +243,7 @@ class PidReader { PidReader(); ~PidReader(); - void Open(char *filename); + void Open(const char *filename); void Close(); bool ReadPidEvent(struct PidEvent *event); void Dispose(struct PidEvent *event); @@ -258,7 +258,7 @@ class MethodReader { MethodReader(); ~MethodReader(); - bool Open(char *filename); + bool Open(const char *filename); void Close(); bool ReadMethod(MethodRec *method_record); |