-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Add a {ObjectFile,SymbolFile}::GetObjectName method #133370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-lldb Author: Jonas Devlieghere (JDevlieghere) ChangesIn #133211, Greg pointed out that the old code would print the static archive (the .a file) rather than the actual object file inside of it. Full diff: https://github.com/llvm/llvm-project/pull/133370.diff 1 Files Affected:
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index e346d588a449f..fff2464c38c12 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -718,6 +718,15 @@ bool SymbolFileDWARFDebugMap::ParseDebugMacros(CompileUnit &comp_unit) {
return false;
}
+static std::string GetObjectName(SymbolFileDWARF &oso_dwarf) {
+ if (ObjectFile *object_file = oso_dwarf.GetObjectFile()) {
+ if (ModuleSP module_sp = object_file->GetModule()) {
+ return module_sp->GetObjectName().GetString();
+ }
+ }
+ return "";
+}
+
void SymbolFileDWARFDebugMap::ForEachSymbolFile(
std::string description,
std::function<IterationAction(SymbolFileDWARF &)> closure) {
@@ -727,12 +736,7 @@ void SymbolFileDWARFDebugMap::ForEachSymbolFile(
/*minimum_report_time=*/std::chrono::milliseconds(20));
for (uint32_t oso_idx = 0; oso_idx < num_oso_idxs; ++oso_idx) {
if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx)) {
- progress.Increment(oso_idx, oso_dwarf->GetObjectFile()
- ? oso_dwarf->GetObjectFile()
- ->GetFileSpec()
- .GetFilename()
- .GetString()
- : "");
+ progress.Increment(oso_idx, GetObjectName(*oso_dwarf));
if (closure(*oso_dwarf) == IterationAction::Stop)
return;
}
|
One common mistake with .o files is to strip the .a file before linking. Then you end up with no debug info even though the original .o file definitely HAS debug info. In that case showing the .o file rather than the usual form libfoo.a(bar.o) would be confusing. |
Add ObjectFile::GetObjectName and SymbolFile::GetObjectName to retrieve the name of the object file, including the `.a` for static libraries. We currently do something similar in CommandObjectTarget, but the code for dumping this is a lot more involved than what's being offered by the new method. We have options to print he full path, the base name, and the directoy of the path and trim it to a specific width.
5011349
to
8af1b71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add ObjectFile::GetObjectName and SymbolFile::GetObjectName to retrieve
the name of the object file, including the
.a
for static libraries.We currently do something similar in CommandObjectTarget, but the code
for dumping this is a lot more involved than what's being offered by the
new method. We have options to print he full path, the base name, and
the directoy of the path and trim it to a specific width.
This is motivated by #133211, where Greg pointed out that the old code would print the static archive (the .a file) rather than the actual object file inside of it.