Mac: add option to dump_syms to mark folded symbols

Bug: google-breakpad:751
Change-Id: I12afcc8399fa9808aace9f465622bd074eab13f4
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4034827
Reviewed-by: Mark Mentovai <mark@chromium.org>
This commit is contained in:
Leonard Grey 2022-12-01 15:20:03 -05:00
parent 9aa786f03d
commit 87b60390f0
3 changed files with 32 additions and 12 deletions

View file

@ -441,10 +441,8 @@ bool DumpSymbols::CreateEmptyModule(scoped_ptr<Module>& module) {
return false; return false;
// Create a module to hold the debugging information. // Create a module to hold the debugging information.
module.reset(new Module(module_name, module.reset(new Module(module_name, "mac", selected_arch_name, identifier,
"mac", "", enable_multiple_));
selected_arch_name,
identifier));
return true; return true;
} }

View file

@ -53,7 +53,9 @@ namespace google_breakpad {
class DumpSymbols { class DumpSymbols {
public: public:
DumpSymbols(SymbolData symbol_data, bool handle_inter_cu_refs) DumpSymbols(SymbolData symbol_data,
bool handle_inter_cu_refs,
bool enable_multiple = false)
: symbol_data_(symbol_data), : symbol_data_(symbol_data),
handle_inter_cu_refs_(handle_inter_cu_refs), handle_inter_cu_refs_(handle_inter_cu_refs),
object_filename_(), object_filename_(),
@ -62,9 +64,9 @@ class DumpSymbols {
from_disk_(false), from_disk_(false),
object_files_(), object_files_(),
selected_object_file_(), selected_object_file_(),
selected_object_name_() {} selected_object_name_(),
~DumpSymbols() { enable_multiple_(enable_multiple) {}
} ~DumpSymbols() = default;
// Prepare to read debugging information from |filename|. |filename| may be // Prepare to read debugging information from |filename|. |filename| may be
// the name of a fat file, a Mach-O file, or a dSYM bundle containing either // the name of a fat file, a Mach-O file, or a dSYM bundle containing either
@ -201,6 +203,12 @@ class DumpSymbols {
// fat binary, it includes an indication of the particular architecture // fat binary, it includes an indication of the particular architecture
// within that binary. // within that binary.
string selected_object_name_; string selected_object_name_;
// Whether symbols sharing an address should be collapsed into a single entry
// and marked with an `m` in the output.
// See: https://crbug.com/google-breakpad/751 and docs at
// docs/symbol_files.md#records-3
bool enable_multiple_;
}; };
} // namespace google_breakpad } // namespace google_breakpad

View file

@ -50,8 +50,14 @@ using std::vector;
struct Options { struct Options {
Options() Options()
: srcPath(), dsymPath(), arch(), header_only(false), : srcPath(),
cfi(true), handle_inter_cu_refs(true), handle_inlines(false) {} dsymPath(),
arch(),
header_only(false),
cfi(true),
handle_inter_cu_refs(true),
handle_inlines(false),
enable_multiple(false) {}
string srcPath; string srcPath;
string dsymPath; string dsymPath;
@ -60,6 +66,7 @@ struct Options {
bool cfi; bool cfi;
bool handle_inter_cu_refs; bool handle_inter_cu_refs;
bool handle_inlines; bool handle_inlines;
bool enable_multiple;
}; };
static bool StackFrameEntryComparator(const Module::StackFrameEntry* a, static bool StackFrameEntryComparator(const Module::StackFrameEntry* a,
@ -139,7 +146,8 @@ static bool Start(const Options& options) {
SymbolData symbol_data = SymbolData symbol_data =
(options.handle_inlines ? INLINES : NO_DATA) | (options.handle_inlines ? INLINES : NO_DATA) |
(options.cfi ? CFI : NO_DATA) | SYMBOLS_AND_FILES; (options.cfi ? CFI : NO_DATA) | SYMBOLS_AND_FILES;
DumpSymbols dump_symbols(symbol_data, options.handle_inter_cu_refs); DumpSymbols dump_symbols(symbol_data, options.handle_inter_cu_refs,
options.enable_multiple);
// For x86_64 binaries, the CFI data is in the __TEXT,__eh_frame of the // For x86_64 binaries, the CFI data is in the __TEXT,__eh_frame of the
// Mach-O file, which is not copied into the dSYM. Whereas in i386, the CFI // Mach-O file, which is not copied into the dSYM. Whereas in i386, the CFI
@ -215,6 +223,9 @@ static void Usage(int argc, const char *argv[]) {
fprintf(stderr, "\t-c: Do not generate CFI section\n"); fprintf(stderr, "\t-c: Do not generate CFI section\n");
fprintf(stderr, "\t-r: Do not handle inter-compilation unit references\n"); fprintf(stderr, "\t-r: Do not handle inter-compilation unit references\n");
fprintf(stderr, "\t-d: Generate INLINE and INLINE_ORIGIN records\n"); fprintf(stderr, "\t-d: Generate INLINE and INLINE_ORIGIN records\n");
fprintf(stderr,
"\t-m: Enable writing the optional 'm' field on FUNC "
"and PUBLIC, denoting multiple symbols for the address.\n");
fprintf(stderr, "\t-h: Usage\n"); fprintf(stderr, "\t-h: Usage\n");
fprintf(stderr, "\t-?: Usage\n"); fprintf(stderr, "\t-?: Usage\n");
} }
@ -224,7 +235,7 @@ static void SetupOptions(int argc, const char *argv[], Options *options) {
extern int optind; extern int optind;
signed char ch; signed char ch;
while ((ch = getopt(argc, (char * const*)argv, "ia:g:crd?h")) != -1) { while ((ch = getopt(argc, (char* const*)argv, "ia:g:crdm?h")) != -1) {
switch (ch) { switch (ch) {
case 'i': case 'i':
options->header_only = true; options->header_only = true;
@ -252,6 +263,9 @@ static void SetupOptions(int argc, const char *argv[], Options *options) {
case 'd': case 'd':
options->handle_inlines = true; options->handle_inlines = true;
break; break;
case 'm':
options->enable_multiple = true;
break;
case '?': case '?':
case 'h': case 'h':
Usage(argc, argv); Usage(argc, argv);