From e219ba182e00794dee6046b01df467e030ca6390 Mon Sep 17 00:00:00 2001 From: luly81 Date: Wed, 2 May 2007 19:13:09 +0000 Subject: [PATCH] Merge Ted's patch for writing symbols to stdout for linux. git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@149 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/linux/dump_symbols.cc | 8 +------- src/common/linux/dump_symbols.h | 2 +- src/tools/linux/dump_syms/dump_syms.cc | 20 ++++++++------------ 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/common/linux/dump_symbols.cc b/src/common/linux/dump_symbols.cc index f102016d..5c2d6254 100644 --- a/src/common/linux/dump_symbols.cc +++ b/src/common/linux/dump_symbols.cc @@ -616,7 +616,7 @@ class MmapWrapper { namespace google_breakpad { bool DumpSymbols::WriteSymbolFile(const std::string &obj_file, - const std::string &symbol_file) { + int sym_fd) { int obj_fd = open(obj_file.c_str(), O_RDONLY); if (obj_fd < 0) return false; @@ -636,16 +636,10 @@ bool DumpSymbols::WriteSymbolFile(const std::string &obj_file, if (!LoadSymbols(elf_header, &symbols)) return false; // Write to symbol file. - int sym_fd = open(symbol_file.c_str(), O_CREAT | O_WRONLY | O_TRUNC, 0666); - if (sym_fd < 0) - return false; - FDWrapper sym_fd_wrapper(sym_fd); if (WriteModuleInfo(sym_fd, elf_header->e_machine, obj_file) && DumpStabSymbols(sym_fd, symbols)) return true; - // Remove the symbol file if failed to write the symbols. - unlink(symbol_file.c_str()); return false; } diff --git a/src/common/linux/dump_symbols.h b/src/common/linux/dump_symbols.h index e0cbdf66..64f4c9e6 100644 --- a/src/common/linux/dump_symbols.h +++ b/src/common/linux/dump_symbols.h @@ -40,7 +40,7 @@ namespace google_breakpad { class DumpSymbols { public: bool WriteSymbolFile(const std::string &obj_file, - const std::string &symbol_file); + int sym_fd); }; } // namespace google_breakpad diff --git a/src/tools/linux/dump_syms/dump_syms.cc b/src/tools/linux/dump_syms/dump_syms.cc index 3eca3745..e7eb0a2d 100644 --- a/src/tools/linux/dump_syms/dump_syms.cc +++ b/src/tools/linux/dump_syms/dump_syms.cc @@ -28,29 +28,25 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include +#include #include "common/linux/dump_symbols.h" using namespace google_breakpad; int main(int argc, char **argv) { - if (argc < 2 || argc > 3) { - fprintf(stderr, - "Usage: %s [output-symbol-file]\n", - argv[0]); + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); return 1; } const char *binary = argv[1]; - std::string symbol_file(binary); - symbol_file += ".sym"; - if (argc == 3) - symbol_file = argv[2]; DumpSymbols dumper; - if (dumper.WriteSymbolFile(binary, symbol_file)) - printf("Symbol file successfully written: %s\n", symbol_file.c_str()); - else - printf("Failed to write symbol file.\n"); + if (!dumper.WriteSymbolFile(binary, fileno(stdout))) { + fprintf(stderr, "Failed to write symbol file.\n"); + return 1; + } + return 0; }