aboutsummaryrefslogtreecommitdiff
path: root/src/common/dwarf_cfi_to_module.h
diff options
context:
space:
mode:
authorjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-07-17 15:14:30 +0000
committerjimblandy <jimblandy@4c0a9323-5329-0410-9bdc-e9ce6186880e>2010-07-17 15:14:30 +0000
commit786275e7195761228374d7c0f5ff02403c7e1ef8 (patch)
tree2d38496971ca3c7eacbbfbb3e240f7b64b4b5a5f /src/common/dwarf_cfi_to_module.h
parentBreakpad Linux dumper: Don't map file into memory a second time just to compu... (diff)
downloadbreakpad-786275e7195761228374d7c0f5ff02403c7e1ef8.tar.xz
Breakpad Linux/Mac symbol dumper: Share duplicate strings that arise in DWARF data.
This patch avoids allocating many copies of identical strings appearing in debugging information. Without this patch, running dump_syms on Mozilla's libxul.so (with 173MiB of debugging information) has a peak resident set of around 450MiB. With this patch, the peak is around 365MiB. a=jimblandy, r=mark git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@626 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common/dwarf_cfi_to_module.h')
-rw-r--r--src/common/dwarf_cfi_to_module.h23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/common/dwarf_cfi_to_module.h b/src/common/dwarf_cfi_to_module.h
index dc11ec53..d29a796c 100644
--- a/src/common/dwarf_cfi_to_module.h
+++ b/src/common/dwarf_cfi_to_module.h
@@ -40,7 +40,9 @@
#define COMMON_LINUX_DWARF_CFI_TO_MODULE_H
#include <assert.h>
+#include <stdio.h>
+#include <set>
#include <string>
#include <vector>
@@ -51,6 +53,7 @@ namespace google_breakpad {
using dwarf2reader::CallFrameInfo;
using google_breakpad::Module;
+using std::set;
using std::string;
using std::vector;
@@ -124,7 +127,8 @@ class DwarfCFIToModule: public CallFrameInfo::Handler {
DwarfCFIToModule(Module *module, const vector<string> &register_names,
Reporter *reporter)
: module_(module), register_names_(register_names), reporter_(reporter),
- entry_(NULL), return_address_(-1) { }
+ entry_(NULL), return_address_(-1), cfa_name_(".cfa"), ra_name_(".ra") {
+ }
virtual ~DwarfCFIToModule() { delete entry_; }
virtual bool Entry(size_t offset, uint64 address, uint64 length,
@@ -168,6 +172,23 @@ class DwarfCFIToModule: public CallFrameInfo::Handler {
// The return address column for that entry.
unsigned return_address_;
+
+ // The names of the return address and canonical frame address. Putting
+ // these here instead of using string literals allows us to share their
+ // texts in reference-counted std::string implementations (all the
+ // popular ones). Many, many rules cite these strings.
+ string cfa_name_, ra_name_;
+
+ // A set of strings used by this CFI. Before storing a string in one of
+ // our data structures, insert it into this set, and then use the string
+ // from the set.
+ //
+ // Because std::string uses reference counting internally, simply using
+ // strings from this set, even if passed by value, assigned, or held
+ // directly in structures and containers (map<string, ...>, for example),
+ // causes those strings to share a single instance of each distinct piece
+ // of text.
+ set<string> common_strings_;
};
} // namespace google_breakpad