aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorjimblandy@gmail.com <jimblandy@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2009-08-05 00:57:48 +0000
committerjimblandy@gmail.com <jimblandy@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2009-08-05 00:57:48 +0000
commit68c8481df65940e90151ff2a6a6bd3c01f73f702 (patch)
tree1825f000785f85d005a97718aa9d3f2cfcf03840 /src/common
parentLinux dumper: Properly separate function names from STABS type data. (diff)
downloadbreakpad-68c8481df65940e90151ff2a6a6bd3c01f73f702.tar.xz
Linux dumper: Make the 'name' field of FuncInfo a std::string instead of a char *.
Because the actual N_FUN strings in the .stabstr section contain type information after the mangled name, representing this information using a pointer into .stabstr, while efficient with memory, makes the FuncInfo data structure STABS-specific: one must know the details of a STABS N_FUN string's syntax to interpret FuncInfo::name. This patch removes this STABS dependency from the data structure, and moves us closer to having an appropriate structure for representing unified STABS and DWARF data. a=jimblandy r=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@375 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/common')
-rw-r--r--src/common/linux/dump_symbols.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc
index 3b2331df..505c517e 100644
--- a/src/common/linux/dump_symbols.cc
+++ b/src/common/linux/dump_symbols.cc
@@ -43,6 +43,7 @@
#include <unistd.h>
#include <algorithm>
+#include <string>
#include <functional>
#include <list>
#include <vector>
@@ -81,7 +82,7 @@ typedef std::list<struct LineInfo> LineInfoList;
// Information of a function.
struct FuncInfo {
// Name of the function.
- const char *name;
+ std::string name;
// Offset from the base of the loading address.
ElfW(Off) rva_to_base;
// Virtual address of the function.
@@ -317,9 +318,16 @@ static int LoadFuncSymbols(struct nlist *list,
}
if (cur_list->n_type == N_FUN) {
struct FuncInfo func_info;
- func_info.name =
- reinterpret_cast<char *>(cur_list->n_un.n_strx +
- stabstr_section->sh_offset);
+ // The STABS data for an N_FUN entry is the function's (mangled)
+ // name, followed by a colon, followed by type information. We
+ // want to retain the name only.
+ const char *stabs_name
+ = reinterpret_cast<char *>(cur_list->n_un.n_strx +
+ stabstr_section->sh_offset);
+ const char *name_end = strchr(stabs_name, ':');
+ if (! name_end)
+ name_end = stabs_name + strlen(stabs_name);
+ func_info.name = std::string(stabs_name, name_end - stabs_name);
func_info.addr = cur_list->n_value;
func_info.rva_to_base = 0;
func_info.size = 0;
@@ -609,12 +617,7 @@ static bool WriteSourceFileInfo(FILE *file, struct SymbolInfo &symbols) {
static bool WriteOneFunction(FILE *file,
const struct FuncInfo &func_info){
- // Discard the ending part of the name.
- std::string func_name(func_info.name);
- std::string::size_type last_colon = func_name.find_first_of(':');
- if (last_colon != std::string::npos)
- func_name = func_name.substr(0, last_colon);
- func_name = Demangle(func_name.c_str());
+ std::string func_name = Demangle(func_info.name.c_str());
if (func_info.size <= 0)
return true;