@@ -1104,6 +1104,7 @@ class CommandObjectSourceList : public CommandObjectParsed {
11041104 bool check_inlines = false ;
11051105 SymbolContextList sc_list;
11061106 size_t num_matches = 0 ;
1107+ uint32_t start_line = m_options.start_line ;
11071108
11081109 if (!m_options.modules .empty ()) {
11091110 ModuleList matching_modules;
@@ -1114,15 +1115,15 @@ class CommandObjectSourceList : public CommandObjectParsed {
11141115 matching_modules.Clear ();
11151116 target.GetImages ().FindModules (module_spec, matching_modules);
11161117 num_matches += matching_modules.ResolveSymbolContextForFilePath (
1117- filename, 0 , check_inlines,
1118+ filename, start_line , check_inlines,
11181119 SymbolContextItem (eSymbolContextModule |
11191120 eSymbolContextCompUnit),
11201121 sc_list);
11211122 }
11221123 }
11231124 } else {
11241125 num_matches = target.GetImages ().ResolveSymbolContextForFilePath (
1125- filename, 0 , check_inlines,
1126+ filename, start_line , check_inlines,
11261127 eSymbolContextModule | eSymbolContextCompUnit, sc_list);
11271128 }
11281129
@@ -1170,8 +1171,37 @@ class CommandObjectSourceList : public CommandObjectParsed {
11701171 if (m_options.num_lines == 0 )
11711172 m_options.num_lines = 10 ;
11721173 const uint32_t column = 0 ;
1174+
1175+ // Headers aren't always in the DWARF but if they have
1176+ // executable code (eg., inlined-functions) then the callsite's file(s)
1177+ // will be found.
1178+ // So if a header was requested and we got a primary file, then look
1179+ // thru its support file(s) for the header.
1180+ lldb::SupportFileSP actual_file_sp =
1181+ sc.comp_unit ->GetPrimarySupportFile ();
1182+ if (llvm::StringRef (m_options.file_name ).ends_with (" .h" )) {
1183+ int support_matches_count = 0 ;
1184+ for (auto &file : sc.comp_unit ->GetSupportFiles ()) {
1185+ if (llvm::StringRef (file->GetSpecOnly ().GetPath ()).ends_with (filename)) {
1186+ actual_file_sp = file;
1187+ ++support_matches_count;
1188+ }
1189+ }
1190+ if (support_matches_count == 0 ) {
1191+ result.AppendErrorWithFormat (
1192+ " No file found for requested header: \" %s.\"\n " ,
1193+ m_options.file_name .c_str ());
1194+ return ;
1195+ } else if (support_matches_count > 1 ) {
1196+ result.AppendErrorWithFormat (
1197+ " Multiple files found for requested header: \" %s.\"\n " ,
1198+ m_options.file_name .c_str ());
1199+ return ;
1200+ }
1201+ }
1202+
11731203 target.GetSourceManager ().DisplaySourceLinesWithLineNumbers (
1174- sc. comp_unit -> GetPrimarySupportFile () ,
1204+ actual_file_sp ,
11751205 m_options.start_line , column, 0 , m_options.num_lines , " " ,
11761206 &result.GetOutputStream (), GetBreakpointLocations ());
11771207
0 commit comments