Commit 5fba86ce authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

Free memory allocated by backtrace_symbols immediately.

R=petermarshall@chromium.org

Bug: v8:6687
Change-Id: Ic447a6cd5cb8a7a251b4820fc82f1f1d033be355
Reviewed-on: https://chromium-review.googlesource.com/612067Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47340}
parent 3b741a94
...@@ -49,14 +49,6 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) { ...@@ -49,14 +49,6 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
AddApiReferences(isolate); AddApiReferences(isolate);
} }
ExternalReferenceTable::~ExternalReferenceTable() {
#ifdef SYMBOLIZE_FUNCTION
for (char** table : symbol_tables_) {
free(table);
}
#endif
}
#ifdef DEBUG #ifdef DEBUG
void ExternalReferenceTable::ResetCount() { void ExternalReferenceTable::ResetCount() {
for (ExternalReferenceEntry& entry : refs_) entry.count = 0; for (ExternalReferenceEntry& entry : refs_) entry.count = 0;
...@@ -70,12 +62,14 @@ void ExternalReferenceTable::PrintCount() { ...@@ -70,12 +62,14 @@ void ExternalReferenceTable::PrintCount() {
} }
#endif // DEBUG #endif // DEBUG
const char* ExternalReferenceTable::ResolveSymbol(void* address, const char* ExternalReferenceTable::ResolveSymbol(void* address) {
std::vector<char**>* tables) {
#ifdef SYMBOLIZE_FUNCTION #ifdef SYMBOLIZE_FUNCTION
char** table = backtrace_symbols(&address, 1); char** names = backtrace_symbols(&address, 1);
if (tables) tables->push_back(table); const char* name = names[0];
return table[0]; // The array of names is malloc'ed. However, each name string is static
// and do not need to be freed.
free(names);
return name;
#else #else
return "<unresolved>"; return "<unresolved>";
#endif // SYMBOLIZE_FUNCTION #endif // SYMBOLIZE_FUNCTION
...@@ -468,11 +462,7 @@ void ExternalReferenceTable::AddApiReferences(Isolate* isolate) { ...@@ -468,11 +462,7 @@ void ExternalReferenceTable::AddApiReferences(Isolate* isolate) {
if (api_external_references != nullptr) { if (api_external_references != nullptr) {
while (*api_external_references != 0) { while (*api_external_references != 0) {
Address address = reinterpret_cast<Address>(*api_external_references); Address address = reinterpret_cast<Address>(*api_external_references);
#ifdef SYMBOLIZE_FUNCTION
Add(address, ResolveSymbol(address, &symbol_tables_));
#else
Add(address, ResolveSymbol(address)); Add(address, ResolveSymbol(address));
#endif
api_external_references++; api_external_references++;
} }
} }
......
...@@ -21,7 +21,6 @@ class Isolate; ...@@ -21,7 +21,6 @@ class Isolate;
class ExternalReferenceTable { class ExternalReferenceTable {
public: public:
static ExternalReferenceTable* instance(Isolate* isolate); static ExternalReferenceTable* instance(Isolate* isolate);
~ExternalReferenceTable();
uint32_t size() const { return static_cast<uint32_t>(refs_.length()); } uint32_t size() const { return static_cast<uint32_t>(refs_.length()); }
Address address(uint32_t i) { return refs_[i].address; } Address address(uint32_t i) { return refs_[i].address; }
...@@ -36,8 +35,7 @@ class ExternalReferenceTable { ...@@ -36,8 +35,7 @@ class ExternalReferenceTable {
void PrintCount(); void PrintCount();
#endif // DEBUG #endif // DEBUG
static const char* ResolveSymbol(void* address, static const char* ResolveSymbol(void* address);
std::vector<char**>* = nullptr);
private: private:
struct ExternalReferenceEntry { struct ExternalReferenceEntry {
...@@ -68,9 +66,6 @@ class ExternalReferenceTable { ...@@ -68,9 +66,6 @@ class ExternalReferenceTable {
void AddApiReferences(Isolate* isolate); void AddApiReferences(Isolate* isolate);
List<ExternalReferenceEntry> refs_; List<ExternalReferenceEntry> refs_;
#ifdef DEBUG
std::vector<char**> symbol_tables_;
#endif
uint32_t api_refs_start_; uint32_t api_refs_start_;
DISALLOW_COPY_AND_ASSIGN(ExternalReferenceTable); DISALLOW_COPY_AND_ASSIGN(ExternalReferenceTable);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment