Skip to content

Commit 692a387

Browse files
committed
rework the logic to be more general
1 parent 0e82340 commit 692a387

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lldb/source/Commands/CommandObjectSource.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,33 +1175,35 @@ class CommandObjectSourceList : public CommandObjectParsed {
11751175
// Headers aren't always in the DWARF but if they have
11761176
// executable code (eg., inlined-functions) then the callsite's
11771177
// file(s) will be found. So if a header was requested and we got a
1178-
// primary file, then look thru its support file(s) for the header.
1179-
lldb::SupportFileSP actual_file_sp =
1178+
// primary file (ie., something with a different name), then look thru
1179+
// its support file(s) for the header.
1180+
lldb::SupportFileSP found_file_sp =
11801181
sc.comp_unit->GetPrimarySupportFile();
1181-
if (llvm::StringRef(m_options.file_name).ends_with(".h")) {
1182+
1183+
if (!llvm::StringRef(found_file_sp->GetSpecOnly().GetPath())
1184+
.ends_with(filename)) {
11821185
int support_matches_count = 0;
11831186
for (auto &file : sc.comp_unit->GetSupportFiles()) {
11841187
if (llvm::StringRef(file->GetSpecOnly().GetPath())
11851188
.ends_with(filename)) {
1186-
actual_file_sp = file;
1189+
found_file_sp = file;
11871190
++support_matches_count;
11881191
}
11891192
}
11901193
if (support_matches_count == 0) {
11911194
result.AppendErrorWithFormat(
1192-
"No file found for requested header: \"%s.\"\n",
1193-
m_options.file_name.c_str());
1195+
"No file found for requested header: \"%s.\"\n", filename);
11941196
return;
11951197
} else if (support_matches_count > 1) {
11961198
result.AppendErrorWithFormat(
11971199
"Multiple files found for requested header: \"%s.\"\n",
1198-
m_options.file_name.c_str());
1200+
filename);
11991201
return;
12001202
}
12011203
}
12021204

12031205
target.GetSourceManager().DisplaySourceLinesWithLineNumbers(
1204-
actual_file_sp, m_options.start_line, column, 0,
1206+
found_file_sp, m_options.start_line, column, 0,
12051207
m_options.num_lines, "", &result.GetOutputStream(),
12061208
GetBreakpointLocations());
12071209

0 commit comments

Comments
 (0)