Release malloced symbol tables
Bug:chromium:617892 Change-Id: I9993191fb632ca49f020e8073e7e409c86932a29 Reviewed-on: https://chromium-review.googlesource.com/485202 Commit-Queue: Hitoshi Yoshida <peria@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Cr-Commit-Position: refs/heads/master@{#44827}
This commit is contained in:
parent
2e01589659
commit
619ff8c540
@ -15,6 +15,7 @@
|
||||
#if defined(DEBUG) && defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID)
|
||||
#define SYMBOLIZE_FUNCTION
|
||||
#include <execinfo.h>
|
||||
#include <vector>
|
||||
#endif // DEBUG && V8_OS_LINUX && !V8_OS_ANDROID
|
||||
|
||||
namespace v8 {
|
||||
@ -49,6 +50,14 @@ 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;
|
||||
@ -62,10 +71,12 @@ void ExternalReferenceTable::PrintCount() {
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
// static
|
||||
const char* ExternalReferenceTable::ResolveSymbol(void* address) {
|
||||
const char* ExternalReferenceTable::ResolveSymbol(void* address,
|
||||
std::vector<char**>* tables) {
|
||||
#ifdef SYMBOLIZE_FUNCTION
|
||||
return backtrace_symbols(&address, 1)[0];
|
||||
char** table = backtrace_symbols(&address, 1);
|
||||
if (tables) tables->push_back(table);
|
||||
return table[0];
|
||||
#else
|
||||
return "<unresolved>";
|
||||
#endif // SYMBOLIZE_FUNCTION
|
||||
@ -458,7 +469,11 @@ 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++;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@
|
||||
#ifndef V8_EXTERNAL_REFERENCE_TABLE_H_
|
||||
#define V8_EXTERNAL_REFERENCE_TABLE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/address-map.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -18,6 +20,7 @@ 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; }
|
||||
@ -32,7 +35,8 @@ class ExternalReferenceTable {
|
||||
void PrintCount();
|
||||
#endif // DEBUG
|
||||
|
||||
static const char* ResolveSymbol(void* address);
|
||||
static const char* ResolveSymbol(void* address,
|
||||
std::vector<char**>* = nullptr);
|
||||
|
||||
private:
|
||||
struct ExternalReferenceEntry {
|
||||
@ -63,6 +67,9 @@ 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);
|
||||
|
Loading…
Reference in New Issue
Block a user