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) {
AddApiReferences(isolate);
}
ExternalReferenceTable::~ExternalReferenceTable() {
#ifdef SYMBOLIZE_FUNCTION
for (char** table : symbol_tables_) {
free(table);
}
#endif
}
#ifdef DEBUG
void ExternalReferenceTable::ResetCount() {
for (ExternalReferenceEntry& entry : refs_) entry.count = 0;
......@@ -70,12 +62,14 @@ void ExternalReferenceTable::PrintCount() {
}
#endif // DEBUG
const char* ExternalReferenceTable::ResolveSymbol(void* address,
std::vector<char**>* tables) {
const char* ExternalReferenceTable::ResolveSymbol(void* address) {
#ifdef SYMBOLIZE_FUNCTION
char** table = backtrace_symbols(&address, 1);
if (tables) tables->push_back(table);
return table[0];
char** names = backtrace_symbols(&address, 1);
const char* name = names[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
return "<unresolved>";
#endif // SYMBOLIZE_FUNCTION
......@@ -468,11 +462,7 @@ void ExternalReferenceTable::AddApiReferences(Isolate* isolate) {
if (api_external_references != nullptr) {
while (*api_external_references != 0) {
Address address = reinterpret_cast<Address>(*api_external_references);
#ifdef SYMBOLIZE_FUNCTION
Add(address, ResolveSymbol(address, &symbol_tables_));
#else
Add(address, ResolveSymbol(address));
#endif
api_external_references++;
}
}
......
......@@ -21,7 +21,6 @@ class Isolate;
class ExternalReferenceTable {
public:
static ExternalReferenceTable* instance(Isolate* isolate);
~ExternalReferenceTable();
uint32_t size() const { return static_cast<uint32_t>(refs_.length()); }
Address address(uint32_t i) { return refs_[i].address; }
......@@ -36,8 +35,7 @@ class ExternalReferenceTable {
void PrintCount();
#endif // DEBUG
static const char* ResolveSymbol(void* address,
std::vector<char**>* = nullptr);
static const char* ResolveSymbol(void* address);
private:
struct ExternalReferenceEntry {
......@@ -68,9 +66,6 @@ class ExternalReferenceTable {
void AddApiReferences(Isolate* isolate);
List<ExternalReferenceEntry> refs_;
#ifdef DEBUG
std::vector<char**> symbol_tables_;
#endif
uint32_t api_refs_start_;
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