[dump_syms/Mac] New -n MODULE arg to Mac dump_syms

Previously, dump_syms always used the basename of the on-disk file as
the Breakpad module name and required that the on-disk filename of the dSYM and binary file match, or it would exit with an error.

Build automation often uses filenames unrelated to the Breakpad module
name, so this CL adds a new optional "-n MODULE" argument to Mac
dump_syms that allows passing in the Breakpad module name from outside.

In this case, the basename of the on-disk file(s) is ignored and
no longer required to match.

Change-Id: Ic38e8cf762c79bce61d289b397293eff6c0039ce
Bug: b/273531493
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/4338857
Reviewed-by: Robert Sesek <rsesek@chromium.org>
This commit is contained in:
Ben Hamilton 2023-03-20 11:45:05 -06:00 committed by Robert Sesek
parent 9bf8d1ec52
commit 9cc38fec8b
3 changed files with 62 additions and 11 deletions

View file

@ -429,7 +429,12 @@ bool DumpSymbols::CreateEmptyModule(scoped_ptr<Module>& module) {
}
// Compute a module name, to appear in the MODULE record.
string module_name = google_breakpad::BaseName(object_filename_);
string module_name;
if (!module_name_.empty()) {
module_name = module_name_;
} else {
module_name = google_breakpad::BaseName(object_filename_);
}
// Choose an identifier string, to appear in the MODULE record.
string identifier = Identifier();

View file

@ -56,7 +56,8 @@ class DumpSymbols {
public:
DumpSymbols(SymbolData symbol_data,
bool handle_inter_cu_refs,
bool enable_multiple = false)
bool enable_multiple = false,
const std::string& module_name = "")
: symbol_data_(symbol_data),
handle_inter_cu_refs_(handle_inter_cu_refs),
object_filename_(),
@ -66,12 +67,18 @@ class DumpSymbols {
object_files_(),
selected_object_file_(),
selected_object_name_(),
enable_multiple_(enable_multiple) {}
enable_multiple_(enable_multiple),
module_name_(module_name) {}
~DumpSymbols() = default;
// 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
// of the above. On success, return true; if there is a problem reading
// of the above.
//
// If |module_name_| is empty, uses the basename of |filename| as the module
// name. Otherwise, uses |module_name_| as the module name.
//
// On success, return true; if there is a problem reading
// |filename|, report it and return false.
bool Read(const std::string& filename);
@ -194,6 +201,10 @@ class DumpSymbols {
// See: https://crbug.com/google-breakpad/751 and docs at
// docs/symbol_files.md#records-3
bool enable_multiple_;
// If non-empty, used as the module name. Otherwise, the basename of
// |object_filename_| is used as the module name.
const std::string module_name_;
};
} // namespace google_breakpad