aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authornealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e>2009-06-05 22:40:28 +0000
committernealsid <nealsid@4c0a9323-5329-0410-9bdc-e9ce6186880e>2009-06-05 22:40:28 +0000
commit0eb52ff8cc719b22cecf0b2e333ae13fbf9293cd (patch)
tree4b0df7aae38adc73e7834469af04eaf59e14f9b2 /src
parentSupport custom URL parameters. Added unit tests for Breakpad. Added (diff)
downloadbreakpad-0eb52ff8cc719b22cecf0b2e333ae13fbf9293cd.tar.xz
Use ctsdio streams for dump_syms for significant speedup. Also contains a makefile fix to build in 32-bit mode, even on 64-bit systems.
A=jim blandy R=nealsid git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@347 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src')
-rw-r--r--src/common/linux/dump_symbols.cc60
-rw-r--r--src/common/linux/dump_symbols.h3
-rw-r--r--src/tools/linux/dump_syms/Makefile2
-rw-r--r--src/tools/linux/dump_syms/dump_syms.cc2
4 files changed, 28 insertions, 39 deletions
diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc
index fd87c0f0..046c7b34 100644
--- a/src/common/linux/dump_symbols.cc
+++ b/src/common/linux/dump_symbols.cc
@@ -169,18 +169,6 @@ static ElfW(Addr) GetLoadingAddress(const ElfW(Phdr) *program_headers,
return 0;
}
-static bool WriteFormat(int fd, const char *fmt, ...) {
- va_list list;
- char buffer[4096];
- ssize_t expected, written;
- va_start(list, fmt);
- vsnprintf(buffer, sizeof(buffer), fmt, list);
- expected = strlen(buffer);
- written = write(fd, buffer, strlen(buffer));
- va_end(list);
- return expected == written;
-}
-
static bool IsValidElf(const ElfW(Ehdr) *elf_header) {
return memcmp(elf_header, ELFMAG, SELFMAG) == 0;
}
@@ -593,7 +581,7 @@ static bool LoadSymbols(ElfW(Ehdr) *elf_header, struct SymbolInfo *symbols) {
return LoadSymbols(stab_section, stabstr_section, loading_addr, symbols);
}
-static bool WriteModuleInfo(int fd,
+static bool WriteModuleInfo(FILE *file,
ElfW(Half) arch,
const std::string &obj_file) {
const char *arch_name = NULL;
@@ -622,26 +610,26 @@ static bool WriteModuleInfo(int fd,
size_t slash_pos = obj_file.find_last_of("/");
if (slash_pos != std::string::npos)
filename = obj_file.substr(slash_pos + 1);
- return WriteFormat(fd, "MODULE Linux %s %s %s\n", arch_name,
- id_no_dash, filename.c_str());
+ return 0 <= fprintf(file, "MODULE Linux %s %s %s\n", arch_name,
+ id_no_dash, filename.c_str());
}
return false;
}
-static bool WriteSourceFileInfo(int fd, const struct SymbolInfo &symbols) {
+static bool WriteSourceFileInfo(FILE *file, const struct SymbolInfo &symbols) {
for (SourceFileInfoList::const_iterator it =
symbols.source_file_info.begin();
it != symbols.source_file_info.end(); it++) {
if (it->source_id != -1) {
const char *name = it->name;
- if (!WriteFormat(fd, "FILE %d %s\n", it->source_id, name))
+ if (0 > fprintf(file, "FILE %d %s\n", it->source_id, name))
return false;
}
}
return true;
}
-static bool WriteOneFunction(int fd,
+static bool WriteOneFunction(FILE *file,
const struct FuncInfo &func_info){
// Discard the ending part of the name.
std::string func_name(func_info.name);
@@ -653,19 +641,19 @@ static bool WriteOneFunction(int fd,
if (func_info.size <= 0)
return true;
- if (WriteFormat(fd, "FUNC %lx %lx %d %s\n",
- func_info.rva_to_base,
- func_info.size,
- func_info.stack_param_size,
- func_name.c_str())) {
+ if (0 <= fprintf(file, "FUNC %lx %lx %d %s\n",
+ (unsigned long) func_info.rva_to_base,
+ (unsigned long) func_info.size,
+ func_info.stack_param_size,
+ func_name.c_str())) {
for (LineInfoList::const_iterator it = func_info.line_info.begin();
it != func_info.line_info.end(); it++) {
const struct LineInfo &line_info = *it;
- if (!WriteFormat(fd, "%lx %lx %d %d\n",
- line_info.rva_to_base,
- line_info.size,
- line_info.line_num,
- line_info.source_id))
+ if (0 > fprintf(file, "%lx %lx %d %d\n",
+ (unsigned long) line_info.rva_to_base,
+ (unsigned long) line_info.size,
+ line_info.line_num,
+ line_info.source_id))
return false;
}
return true;
@@ -673,7 +661,7 @@ static bool WriteOneFunction(int fd,
return false;
}
-static bool WriteFunctionInfo(int fd, const struct SymbolInfo &symbols) {
+static bool WriteFunctionInfo(FILE *file, const struct SymbolInfo &symbols) {
for (SourceFileInfoList::const_iterator it =
symbols.source_file_info.begin();
it != symbols.source_file_info.end(); it++) {
@@ -681,16 +669,16 @@ static bool WriteFunctionInfo(int fd, const struct SymbolInfo &symbols) {
for (FuncInfoList::const_iterator fiIt = file_info.func_info.begin();
fiIt != file_info.func_info.end(); fiIt++) {
const struct FuncInfo &func_info = *fiIt;
- if (!WriteOneFunction(fd, func_info))
+ if (!WriteOneFunction(file, func_info))
return false;
}
}
return true;
}
-static bool DumpStabSymbols(int fd, const struct SymbolInfo &symbols) {
- return WriteSourceFileInfo(fd, symbols) &&
- WriteFunctionInfo(fd, symbols);
+static bool DumpStabSymbols(FILE *file, const struct SymbolInfo &symbols) {
+ return WriteSourceFileInfo(file, symbols) &&
+ WriteFunctionInfo(file, symbols);
}
//
@@ -750,7 +738,7 @@ class MmapWrapper {
namespace google_breakpad {
bool DumpSymbols::WriteSymbolFile(const std::string &obj_file,
- int sym_fd) {
+ FILE *sym_file) {
int obj_fd = open(obj_file.c_str(), O_RDONLY);
if (obj_fd < 0)
return false;
@@ -772,8 +760,8 @@ bool DumpSymbols::WriteSymbolFile(const std::string &obj_file,
if (!LoadSymbols(elf_header, &symbols))
return false;
// Write to symbol file.
- if (WriteModuleInfo(sym_fd, elf_header->e_machine, obj_file) &&
- DumpStabSymbols(sym_fd, symbols))
+ if (WriteModuleInfo(sym_file, elf_header->e_machine, obj_file) &&
+ DumpStabSymbols(sym_file, symbols))
return true;
return false;
diff --git a/src/common/linux/dump_symbols.h b/src/common/linux/dump_symbols.h
index 64f4c9e6..03e61709 100644
--- a/src/common/linux/dump_symbols.h
+++ b/src/common/linux/dump_symbols.h
@@ -34,13 +34,14 @@
#define COMMON_LINUX_DUMP_SYMBOLS_H__
#include <string>
+#include <cstdio>
namespace google_breakpad {
class DumpSymbols {
public:
bool WriteSymbolFile(const std::string &obj_file,
- int sym_fd);
+ FILE *sym_file);
};
} // namespace google_breakpad
diff --git a/src/tools/linux/dump_syms/Makefile b/src/tools/linux/dump_syms/Makefile
index 7d74abad..ce60a42b 100644
--- a/src/tools/linux/dump_syms/Makefile
+++ b/src/tools/linux/dump_syms/Makefile
@@ -1,7 +1,7 @@
CXX=g++
CC=gcc
-CXXFLAGS=-gstabs -I../../.. -DNDEBUG -Wall -D_REENTRANT
+CXXFLAGS=-gstabs -I../../.. -DNDEBUG -Wall -D_REENTRANT -m32
.PHONY:all clean
diff --git a/src/tools/linux/dump_syms/dump_syms.cc b/src/tools/linux/dump_syms/dump_syms.cc
index e7eb0a2d..f75abef8 100644
--- a/src/tools/linux/dump_syms/dump_syms.cc
+++ b/src/tools/linux/dump_syms/dump_syms.cc
@@ -43,7 +43,7 @@ int main(int argc, char **argv) {
const char *binary = argv[1];
DumpSymbols dumper;
- if (!dumper.WriteSymbolFile(binary, fileno(stdout))) {
+ if (!dumper.WriteSymbolFile(binary, stdout)) {
fprintf(stderr, "Failed to write symbol file.\n");
return 1;
}