LLDB mainline
SymbolContext.cpp
Go to the documentation of this file.
1//===-- SymbolContext.cpp -------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11#include "lldb/Core/Address.h"
12#include "lldb/Core/Debugger.h"
13#include "lldb/Core/Module.h"
15#include "lldb/Host/Host.h"
16#include "lldb/Symbol/Block.h"
19#include "lldb/Symbol/Symbol.h"
24#include "lldb/Target/Target.h"
26#include "lldb/Utility/Log.h"
27#include "lldb/Utility/Stream.h"
30
31using namespace lldb;
32using namespace lldb_private;
33
34SymbolContext::SymbolContext() : target_sp(), module_sp(), line_entry() {}
35
37 Block *b, LineEntry *le, Symbol *s)
38 : target_sp(), module_sp(m), comp_unit(cu), function(f), block(b),
39 line_entry(), symbol(s) {
40 if (le)
41 line_entry = *le;
42}
43
45 CompileUnit *cu, Function *f, Block *b,
46 LineEntry *le, Symbol *s)
47 : target_sp(t), module_sp(m), comp_unit(cu), function(f), block(b),
48 line_entry(), symbol(s) {
49 if (le)
50 line_entry = *le;
51}
52
54 : target_sp(), module_sp(), line_entry() {
55 sc_scope->CalculateSymbolContext(this);
56}
57
59
60void SymbolContext::Clear(bool clear_target) {
61 if (clear_target)
62 target_sp.reset();
63 module_sp.reset();
64 comp_unit = nullptr;
65 function = nullptr;
66 block = nullptr;
68 symbol = nullptr;
69 variable = nullptr;
70}
71
73 Stream *s, ExecutionContextScope *exe_scope, const Address &addr,
74 bool show_fullpaths, bool show_module, bool show_inlined_frames,
75 bool show_function_arguments, bool show_function_name,
76 bool show_function_display_name,
77 std::optional<Stream::HighlightSettings> settings) const {
78 bool dumped_something = false;
79 if (show_module && module_sp) {
80 if (show_fullpaths)
81 *s << module_sp->GetFileSpec();
82 else
83 *s << module_sp->GetFileSpec().GetFilename();
84 s->PutChar('`');
85 dumped_something = true;
86 }
87 if (function != nullptr) {
88 SymbolContext inline_parent_sc;
89 Address inline_parent_addr;
90 if (!show_function_name) {
91 s->Printf("<");
92 dumped_something = true;
93 } else {
94 ConstString name;
95 if (!show_function_arguments)
97 if (!name && show_function_display_name)
98 name = function->GetDisplayName();
99 if (!name)
100 name = function->GetName();
101 if (name)
102 s->PutCStringColorHighlighted(name.GetStringRef(), settings);
103 }
104
105 if (addr.IsValid()) {
106 const addr_t function_offset =
107 addr.GetOffset() -
109 if (!show_function_name) {
110 // Print +offset even if offset is 0
111 dumped_something = true;
112 s->Printf("+%" PRIu64 ">", function_offset);
113 } else if (function_offset) {
114 dumped_something = true;
115 s->Printf(" + %" PRIu64, function_offset);
116 }
117 }
118
119 if (GetParentOfInlinedScope(addr, inline_parent_sc, inline_parent_addr)) {
120 dumped_something = true;
121 Block *inlined_block = block->GetContainingInlinedBlock();
122 const InlineFunctionInfo *inlined_block_info =
123 inlined_block->GetInlinedFunctionInfo();
124 s->Printf(" [inlined] %s", inlined_block_info->GetName().GetCString());
125
126 lldb_private::AddressRange block_range;
127 if (inlined_block->GetRangeContainingAddress(addr, block_range)) {
128 const addr_t inlined_function_offset =
129 addr.GetOffset() - block_range.GetBaseAddress().GetOffset();
130 if (inlined_function_offset) {
131 s->Printf(" + %" PRIu64, inlined_function_offset);
132 }
133 }
134 // "line_entry" will always be valid as GetParentOfInlinedScope(...) will
135 // fill it in correctly with the calling file and line. Previous code
136 // was extracting the calling file and line from inlined_block_info and
137 // using it right away which is not correct. On the first call to this
138 // function "line_entry" will contain the actual line table entry. On
139 // susequent calls "line_entry" will contain the calling file and line
140 // from the previous inline info.
141 if (line_entry.IsValid()) {
142 s->PutCString(" at ");
143 line_entry.DumpStopContext(s, show_fullpaths);
144 }
145
146 if (show_inlined_frames) {
147 s->EOL();
148 s->Indent();
149 const bool show_function_name = true;
150 return inline_parent_sc.DumpStopContext(
151 s, exe_scope, inline_parent_addr, show_fullpaths, show_module,
152 show_inlined_frames, show_function_arguments, show_function_name,
153 show_function_display_name);
154 }
155 } else {
156 if (line_entry.IsValid()) {
157 dumped_something = true;
158 s->PutCString(" at ");
159 if (line_entry.DumpStopContext(s, show_fullpaths))
160 dumped_something = true;
161 }
162 }
163 } else if (symbol != nullptr) {
164 if (!show_function_name) {
165 s->Printf("<");
166 dumped_something = true;
167 } else if (symbol->GetName()) {
168 dumped_something = true;
170 s->PutCString("symbol stub for: ");
171 ConstString name;
172 if (show_function_display_name)
173 name = symbol->GetDisplayName();
174 if (!name)
175 name = symbol->GetName();
176 s->PutCStringColorHighlighted(name.GetStringRef(), settings);
177 }
178
179 if (addr.IsValid() && symbol->ValueIsAddress()) {
180 const addr_t symbol_offset =
182 if (!show_function_name) {
183 // Print +offset even if offset is 0
184 dumped_something = true;
185 s->Printf("+%" PRIu64 ">", symbol_offset);
186 } else if (symbol_offset) {
187 dumped_something = true;
188 s->Printf(" + %" PRIu64, symbol_offset);
189 }
190 }
191 } else if (addr.IsValid()) {
193 dumped_something = true;
194 }
195 return dumped_something;
196}
197
199 Stream *s, lldb::DescriptionLevel level, Target *target,
200 std::optional<Stream::HighlightSettings> settings) const {
201 if (module_sp) {
202 s->Indent(" Module: file = \"");
203 module_sp->GetFileSpec().Dump(s->AsRawOstream());
204 *s << '"';
205 if (module_sp->GetArchitecture().IsValid())
206 s->Printf(", arch = \"%s\"",
207 module_sp->GetArchitecture().GetArchitectureName());
208 s->EOL();
209 }
210
211 if (comp_unit != nullptr) {
212 s->Indent("CompileUnit: ");
213 comp_unit->GetDescription(s, level);
214 s->EOL();
215 }
216
217 if (function != nullptr) {
218 s->Indent(" Function: ");
219 function->GetDescription(s, level, target);
220 s->EOL();
221
222 Type *func_type = function->GetType();
223 if (func_type) {
224 s->Indent(" FuncType: ");
225 func_type->GetDescription(s, level, false, target);
226 s->EOL();
227 }
228 }
229
230 if (block != nullptr) {
231 std::vector<Block *> blocks;
232 blocks.push_back(block);
233 Block *parent_block = block->GetParent();
234
235 while (parent_block) {
236 blocks.push_back(parent_block);
237 parent_block = parent_block->GetParent();
238 }
239 std::vector<Block *>::reverse_iterator pos;
240 std::vector<Block *>::reverse_iterator begin = blocks.rbegin();
241 std::vector<Block *>::reverse_iterator end = blocks.rend();
242 for (pos = begin; pos != end; ++pos) {
243 if (pos == begin)
244 s->Indent(" Blocks: ");
245 else
246 s->Indent(" ");
247 (*pos)->GetDescription(s, function, level, target);
248 s->EOL();
249 }
250 }
251
252 if (line_entry.IsValid()) {
253 s->Indent(" LineEntry: ");
254 line_entry.GetDescription(s, level, comp_unit, target, false);
255 s->EOL();
256 }
257
258 if (symbol != nullptr) {
259 s->Indent(" Symbol: ");
260 symbol->GetDescription(s, level, target, settings);
261 s->EOL();
262 }
263
264 if (variable != nullptr) {
265 s->Indent(" Variable: ");
266
267 s->Printf("id = {0x%8.8" PRIx64 "}, ", variable->GetID());
268
269 switch (variable->GetScope()) {
271 s->PutCString("kind = global, ");
272 break;
273
275 s->PutCString("kind = static, ");
276 break;
277
279 s->PutCString("kind = argument, ");
280 break;
281
283 s->PutCString("kind = local, ");
284 break;
285
287 s->PutCString("kind = thread local, ");
288 break;
289
290 default:
291 break;
292 }
293
294 s->Printf("name = \"%s\"\n", variable->GetName().GetCString());
295 }
296}
297
299 uint32_t resolved_mask = 0;
300 if (target_sp)
301 resolved_mask |= eSymbolContextTarget;
302 if (module_sp)
303 resolved_mask |= eSymbolContextModule;
304 if (comp_unit)
305 resolved_mask |= eSymbolContextCompUnit;
306 if (function)
307 resolved_mask |= eSymbolContextFunction;
308 if (block)
309 resolved_mask |= eSymbolContextBlock;
310 if (line_entry.IsValid())
311 resolved_mask |= eSymbolContextLineEntry;
312 if (symbol)
313 resolved_mask |= eSymbolContextSymbol;
314 if (variable)
315 resolved_mask |= eSymbolContextVariable;
316 return resolved_mask;
317}
318
319void SymbolContext::Dump(Stream *s, Target *target) const {
320 *s << this << ": ";
321 s->Indent();
322 s->PutCString("SymbolContext");
323 s->IndentMore();
324 s->EOL();
325 s->IndentMore();
326 s->Indent();
327 *s << "Module = " << module_sp.get() << ' ';
328 if (module_sp)
329 module_sp->GetFileSpec().Dump(s->AsRawOstream());
330 s->EOL();
331 s->Indent();
332 *s << "CompileUnit = " << comp_unit;
333 if (comp_unit != nullptr)
334 s->Format(" {{{0:x-16}} {1}", comp_unit->GetID(),
336 s->EOL();
337 s->Indent();
338 *s << "Function = " << function;
339 if (function != nullptr) {
340 s->Format(" {{{0:x-16}} {1}, address-range = ", function->GetID(),
341 function->GetType()->GetName());
344 s->EOL();
345 s->Indent();
346 Type *func_type = function->GetType();
347 if (func_type) {
348 *s << " Type = ";
349 func_type->Dump(s, false);
350 }
351 }
352 s->EOL();
353 s->Indent();
354 *s << "Block = " << block;
355 if (block != nullptr)
356 s->Format(" {{{0:x-16}}", block->GetID());
357 s->EOL();
358 s->Indent();
359 *s << "LineEntry = ";
362 s->EOL();
363 s->Indent();
364 *s << "Symbol = " << symbol;
365 if (symbol != nullptr && symbol->GetMangled())
366 *s << ' ' << symbol->GetName().AsCString();
367 s->EOL();
368 *s << "Variable = " << variable;
369 if (variable != nullptr) {
370 s->Format(" {{{0:x-16}} {1}", variable->GetID(),
371 variable->GetType()->GetName());
372 s->EOL();
373 }
374 s->IndentLess();
375 s->IndentLess();
376}
377
379 const SymbolContext &rhs) {
380 return lhs.function == rhs.function && lhs.symbol == rhs.symbol &&
381 lhs.module_sp.get() == rhs.module_sp.get() &&
382 lhs.comp_unit == rhs.comp_unit &&
383 lhs.target_sp.get() == rhs.target_sp.get() &&
385 lhs.variable == rhs.variable;
386}
387
389 const SymbolContext &rhs) {
390 return !(lhs == rhs);
391}
392
393bool SymbolContext::GetAddressRange(uint32_t scope, uint32_t range_idx,
394 bool use_inline_block_range,
395 AddressRange &range) const {
396 if ((scope & eSymbolContextLineEntry) && line_entry.IsValid()) {
397 range = line_entry.range;
398 return true;
399 }
400
401 if ((scope & eSymbolContextBlock) && (block != nullptr)) {
402 if (use_inline_block_range) {
403 Block *inline_block = block->GetContainingInlinedBlock();
404 if (inline_block)
405 return inline_block->GetRangeAtIndex(range_idx, range);
406 } else {
407 return block->GetRangeAtIndex(range_idx, range);
408 }
409 }
410
411 if ((scope & eSymbolContextFunction) && (function != nullptr)) {
412 if (range_idx == 0) {
413 range = function->GetAddressRange();
414 return true;
415 }
416 }
417
418 if ((scope & eSymbolContextSymbol) && (symbol != nullptr)) {
419 if (range_idx == 0) {
420 if (symbol->ValueIsAddress()) {
423 return true;
424 }
425 }
426 }
427 range.Clear();
428 return false;
429}
430
432 LanguageType lang;
433 if (function && (lang = function->GetLanguage()) != eLanguageTypeUnknown) {
434 return lang;
435 } else if (variable &&
437 return lang;
438 } else if (symbol && (lang = symbol->GetLanguage()) != eLanguageTypeUnknown) {
439 return lang;
440 } else if (comp_unit &&
442 return lang;
443 } else if (symbol) {
444 // If all else fails, try to guess the language from the name.
445 return symbol->GetMangled().GuessLanguage();
446 }
448}
449
451 SymbolContext &next_frame_sc,
452 Address &next_frame_pc) const {
453 next_frame_sc.Clear(false);
454 next_frame_pc.Clear();
455
456 if (block) {
457 // const addr_t curr_frame_file_addr = curr_frame_pc.GetFileAddress();
458
459 // In order to get the parent of an inlined function we first need to see
460 // if we are in an inlined block as "this->block" could be an inlined
461 // block, or a parent of "block" could be. So lets check if this block or
462 // one of this blocks parents is an inlined function.
463 Block *curr_inlined_block = block->GetContainingInlinedBlock();
464 if (curr_inlined_block) {
465 // "this->block" is contained in an inline function block, so to get the
466 // scope above the inlined block, we get the parent of the inlined block
467 // itself
468 Block *next_frame_block = curr_inlined_block->GetParent();
469 // Now calculate the symbol context of the containing block
470 next_frame_block->CalculateSymbolContext(&next_frame_sc);
471
472 // If we get here we weren't able to find the return line entry using the
473 // nesting of the blocks and the line table. So just use the call site
474 // info from our inlined block.
475
476 AddressRange range;
477 if (curr_inlined_block->GetRangeContainingAddress(curr_frame_pc, range)) {
478 // To see there this new frame block it, we need to look at the call
479 // site information from
480 const InlineFunctionInfo *curr_inlined_block_inlined_info =
481 curr_inlined_block->GetInlinedFunctionInfo();
482 next_frame_pc = range.GetBaseAddress();
483 next_frame_sc.line_entry.range.GetBaseAddress() = next_frame_pc;
484 next_frame_sc.line_entry.file_sp = std::make_shared<SupportFile>(
485 curr_inlined_block_inlined_info->GetCallSite().GetFile());
486 next_frame_sc.line_entry.original_file_sp =
487 std::make_shared<SupportFile>(
488 curr_inlined_block_inlined_info->GetCallSite().GetFile());
489 next_frame_sc.line_entry.line =
490 curr_inlined_block_inlined_info->GetCallSite().GetLine();
491 next_frame_sc.line_entry.column =
492 curr_inlined_block_inlined_info->GetCallSite().GetColumn();
493 return true;
494 } else {
496
497 if (log) {
498 LLDB_LOGF(
499 log,
500 "warning: inlined block 0x%8.8" PRIx64
501 " doesn't have a range that contains file address 0x%" PRIx64,
502 curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress());
503 }
504#ifdef LLDB_CONFIGURATION_DEBUG
505 else {
506 ObjectFile *objfile = nullptr;
507 if (module_sp) {
508 if (SymbolFile *symbol_file = module_sp->GetSymbolFile())
509 objfile = symbol_file->GetObjectFile();
510 }
511 if (objfile) {
512 Debugger::ReportWarning(llvm::formatv(
513 "inlined block {0:x} doesn't have a range that contains file "
514 "address {1:x} in {2}",
515 curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress(),
516 objfile->GetFileSpec().GetPath()));
517 } else {
518 Debugger::ReportWarning(llvm::formatv(
519 "inlined block {0:x} doesn't have a range that contains file "
520 "address {1:x}",
521 curr_inlined_block->GetID(), curr_frame_pc.GetFileAddress()));
522 }
523 }
524#endif
525 }
526 }
527 }
528
529 return false;
530}
531
533 if (function) {
534 if (block) {
535 // If this symbol context has a block, check to see if this block is
536 // itself, or is contained within a block with inlined function
537 // information. If so, then the inlined block is the block that defines
538 // the function.
539 Block *inlined_block = block->GetContainingInlinedBlock();
540 if (inlined_block)
541 return inlined_block;
542
543 // The block in this symbol context is not inside an inlined block, so
544 // the block that defines the function is the function's top level block,
545 // which is returned below.
546 }
547
548 // There is no block information in this symbol context, so we must assume
549 // that the block that is desired is the top level block of the function
550 // itself.
551 return &function->GetBlock(true);
552 }
553 return nullptr;
554}
555
558
559 if (Block *function_block = GetFunctionBlock())
560 if (CompilerDeclContext decl_ctx = function_block->GetDeclContext())
561 lang_type = decl_ctx.GetLanguage();
562
563 if (lang_type == eLanguageTypeUnknown)
564 lang_type = GetLanguage();
565
566 if (auto *lang = Language::FindPlugin(lang_type))
567 return lang->GetInstanceVariableName();
568
569 return {};
570}
571
572void SymbolContext::SortTypeList(TypeMap &type_map, TypeList &type_list) const {
573 Block *curr_block = block;
574 bool isInlinedblock = false;
575 if (curr_block != nullptr &&
576 curr_block->GetContainingInlinedBlock() != nullptr)
577 isInlinedblock = true;
578
579 // Find all types that match the current block if we have one and put them
580 // first in the list. Keep iterating up through all blocks.
581 while (curr_block != nullptr && !isInlinedblock) {
582 type_map.ForEach(
583 [curr_block, &type_list](const lldb::TypeSP &type_sp) -> bool {
584 SymbolContextScope *scs = type_sp->GetSymbolContextScope();
585 if (scs && curr_block == scs->CalculateSymbolContextBlock())
586 type_list.Insert(type_sp);
587 return true; // Keep iterating
588 });
589
590 // Remove any entries that are now in "type_list" from "type_map" since we
591 // can't remove from type_map while iterating
592 type_list.ForEach([&type_map](const lldb::TypeSP &type_sp) -> bool {
593 type_map.Remove(type_sp);
594 return true; // Keep iterating
595 });
596 curr_block = curr_block->GetParent();
597 }
598 // Find all types that match the current function, if we have onem, and put
599 // them next in the list.
600 if (function != nullptr && !type_map.Empty()) {
601 const size_t old_type_list_size = type_list.GetSize();
602 type_map.ForEach([this, &type_list](const lldb::TypeSP &type_sp) -> bool {
603 SymbolContextScope *scs = type_sp->GetSymbolContextScope();
604 if (scs && function == scs->CalculateSymbolContextFunction())
605 type_list.Insert(type_sp);
606 return true; // Keep iterating
607 });
608
609 // Remove any entries that are now in "type_list" from "type_map" since we
610 // can't remove from type_map while iterating
611 const size_t new_type_list_size = type_list.GetSize();
612 if (new_type_list_size > old_type_list_size) {
613 for (size_t i = old_type_list_size; i < new_type_list_size; ++i)
614 type_map.Remove(type_list.GetTypeAtIndex(i));
615 }
616 }
617 // Find all types that match the current compile unit, if we have one, and
618 // put them next in the list.
619 if (comp_unit != nullptr && !type_map.Empty()) {
620 const size_t old_type_list_size = type_list.GetSize();
621
622 type_map.ForEach([this, &type_list](const lldb::TypeSP &type_sp) -> bool {
623 SymbolContextScope *scs = type_sp->GetSymbolContextScope();
624 if (scs && comp_unit == scs->CalculateSymbolContextCompileUnit())
625 type_list.Insert(type_sp);
626 return true; // Keep iterating
627 });
628
629 // Remove any entries that are now in "type_list" from "type_map" since we
630 // can't remove from type_map while iterating
631 const size_t new_type_list_size = type_list.GetSize();
632 if (new_type_list_size > old_type_list_size) {
633 for (size_t i = old_type_list_size; i < new_type_list_size; ++i)
634 type_map.Remove(type_list.GetTypeAtIndex(i));
635 }
636 }
637 // Find all types that match the current module, if we have one, and put them
638 // next in the list.
639 if (module_sp && !type_map.Empty()) {
640 const size_t old_type_list_size = type_list.GetSize();
641 type_map.ForEach([this, &type_list](const lldb::TypeSP &type_sp) -> bool {
642 SymbolContextScope *scs = type_sp->GetSymbolContextScope();
643 if (scs && module_sp == scs->CalculateSymbolContextModule())
644 type_list.Insert(type_sp);
645 return true; // Keep iterating
646 });
647 // Remove any entries that are now in "type_list" from "type_map" since we
648 // can't remove from type_map while iterating
649 const size_t new_type_list_size = type_list.GetSize();
650 if (new_type_list_size > old_type_list_size) {
651 for (size_t i = old_type_list_size; i < new_type_list_size; ++i)
652 type_map.Remove(type_list.GetTypeAtIndex(i));
653 }
654 }
655 // Any types that are left get copied into the list an any order.
656 if (!type_map.Empty()) {
657 type_map.ForEach([&type_list](const lldb::TypeSP &type_sp) -> bool {
658 type_list.Insert(type_sp);
659 return true; // Keep iterating
660 });
661 }
662}
663
666 if (function) {
667 if (block) {
668 Block *inlined_block = block->GetContainingInlinedBlock();
669
670 if (inlined_block) {
671 const InlineFunctionInfo *inline_info =
672 inlined_block->GetInlinedFunctionInfo();
673 if (inline_info)
674 return inline_info->GetName();
675 }
676 }
677 return function->GetMangled().GetName(preference);
678 } else if (symbol && symbol->ValueIsAddress()) {
679 return symbol->GetMangled().GetName(preference);
680 } else {
681 // No function, return an empty string.
682 return ConstString();
683 }
684}
685
688 Address start_addr;
689 if (block) {
690 Block *inlined_block = block->GetContainingInlinedBlock();
691 if (inlined_block) {
692 if (inlined_block->GetStartAddress(start_addr)) {
694 return line_entry;
695 }
696 return LineEntry();
697 }
698 }
699
700 if (function) {
704 return line_entry;
705 }
706 return LineEntry();
707}
708
710 AddressRange &range,
711 Status &error) {
712 if (!line_entry.IsValid()) {
713 error.SetErrorString("Symbol context has no line table.");
714 return false;
715 }
716
717 range = line_entry.range;
718 if (line_entry.line > end_line) {
719 error.SetErrorStringWithFormat(
720 "end line option %d must be after the current line: %d", end_line,
722 return false;
723 }
724
725 uint32_t line_index = 0;
726 bool found = false;
727 while (true) {
728 LineEntry this_line;
729 line_index = comp_unit->FindLineEntry(line_index, line_entry.line, nullptr,
730 false, &this_line);
731 if (line_index == UINT32_MAX)
732 break;
733 if (LineEntry::Compare(this_line, line_entry) == 0) {
734 found = true;
735 break;
736 }
737 }
738
739 LineEntry end_entry;
740 if (!found) {
741 // Can't find the index of the SymbolContext's line entry in the
742 // SymbolContext's CompUnit.
743 error.SetErrorString(
744 "Can't find the current line entry in the CompUnit - can't process "
745 "the end-line option");
746 return false;
747 }
748
749 line_index = comp_unit->FindLineEntry(line_index, end_line, nullptr, false,
750 &end_entry);
751 if (line_index == UINT32_MAX) {
752 error.SetErrorStringWithFormat(
753 "could not find a line table entry corresponding "
754 "to end line number %d",
755 end_line);
756 return false;
757 }
758
759 Block *func_block = GetFunctionBlock();
760 if (func_block && func_block->GetRangeIndexContainingAddress(
761 end_entry.range.GetBaseAddress()) == UINT32_MAX) {
762 error.SetErrorStringWithFormat(
763 "end line number %d is not contained within the current function.",
764 end_line);
765 return false;
766 }
767
768 lldb::addr_t range_size = end_entry.range.GetBaseAddress().GetFileAddress() -
770 range.SetByteSize(range_size);
771 return true;
772}
773
775 Status &error) {
776 error.Clear();
777
778 if (!target_sp) {
779 return nullptr;
780 }
781
782 Target &target = *target_sp;
783 Module *module = module_sp.get();
784
785 auto ProcessMatches = [this, &name, &target,
786 module](const SymbolContextList &sc_list,
787 Status &error) -> const Symbol * {
788 llvm::SmallVector<const Symbol *, 1> external_symbols;
789 llvm::SmallVector<const Symbol *, 1> internal_symbols;
790 for (const SymbolContext &sym_ctx : sc_list) {
791 if (sym_ctx.symbol) {
792 const Symbol *symbol = sym_ctx.symbol;
793 const Address sym_address = symbol->GetAddress();
794
795 if (sym_address.IsValid()) {
796 switch (symbol->GetType()) {
797 case eSymbolTypeData:
804 // If the demangled name was synthesized, then don't use it for
805 // expressions. Only let the symbol match if the mangled named
806 // matches for these symbols.
807 if (symbol->GetMangled().GetMangledName() != name)
808 break;
809 }
810 if (symbol->IsExternal()) {
811 external_symbols.push_back(symbol);
812 } else {
813 internal_symbols.push_back(symbol);
814 }
815 break;
817 ConstString reexport_name = symbol->GetReExportedSymbolName();
818 if (reexport_name) {
819 ModuleSP reexport_module_sp;
820 ModuleSpec reexport_module_spec;
821 reexport_module_spec.GetPlatformFileSpec() =
823 if (reexport_module_spec.GetPlatformFileSpec()) {
824 reexport_module_sp =
825 target.GetImages().FindFirstModule(reexport_module_spec);
826 if (!reexport_module_sp) {
827 reexport_module_spec.GetPlatformFileSpec().ClearDirectory();
828 reexport_module_sp =
829 target.GetImages().FindFirstModule(reexport_module_spec);
830 }
831 }
832 // Don't allow us to try and resolve a re-exported symbol if it
833 // is the same as the current symbol
834 if (name == symbol->GetReExportedSymbolName() &&
835 module == reexport_module_sp.get())
836 return nullptr;
837
839 error);
840 }
841 } break;
842
843 case eSymbolTypeCode: // We already lookup functions elsewhere
845 case eSymbolTypeLocal:
846 case eSymbolTypeParam:
854 case eSymbolTypeBlock:
865 break;
866 }
867 }
868 }
869 }
870
871 if (external_symbols.size() > 1) {
872 StreamString ss;
873 ss.Printf("Multiple external symbols found for '%s'\n", name.AsCString());
874 for (const Symbol *symbol : external_symbols) {
876 }
877 ss.PutChar('\n');
878 error.SetErrorString(ss.GetData());
879 return nullptr;
880 } else if (external_symbols.size()) {
881 return external_symbols[0];
882 } else if (internal_symbols.size() > 1) {
883 StreamString ss;
884 ss.Printf("Multiple internal symbols found for '%s'\n", name.AsCString());
885 for (const Symbol *symbol : internal_symbols) {
887 ss.PutChar('\n');
888 }
889 error.SetErrorString(ss.GetData());
890 return nullptr;
891 } else if (internal_symbols.size()) {
892 return internal_symbols[0];
893 } else {
894 return nullptr;
895 }
896 };
897
898 if (module) {
899 SymbolContextList sc_list;
900 module->FindSymbolsWithNameAndType(name, eSymbolTypeAny, sc_list);
901 const Symbol *const module_symbol = ProcessMatches(sc_list, error);
902
903 if (!error.Success()) {
904 return nullptr;
905 } else if (module_symbol) {
906 return module_symbol;
907 }
908 }
909
910 {
911 SymbolContextList sc_list;
913 sc_list);
914 const Symbol *const target_symbol = ProcessMatches(sc_list, error);
915
916 if (!error.Success()) {
917 return nullptr;
918 } else if (target_symbol) {
919 return target_symbol;
920 }
921 }
922
923 return nullptr; // no error; we just didn't find anything
924}
925
926//
927// SymbolContextSpecifier
928//
929
931 : m_target_sp(target_sp), m_module_spec(), m_module_sp(), m_file_spec_up(),
932 m_start_line(0), m_end_line(0), m_function_spec(), m_class_name(),
933 m_address_range_up(), m_type(eNothingSpecified) {}
934
936
938 SpecificationType type) {
939 bool return_value = true;
940 switch (type) {
942 Clear();
943 break;
945 m_start_line = line_no;
947 break;
949 m_end_line = line_no;
951 break;
952 default:
953 return_value = false;
954 break;
955 }
956 return return_value;
957}
958
959bool SymbolContextSpecifier::AddSpecification(const char *spec_string,
960 SpecificationType type) {
961 bool return_value = true;
962 switch (type) {
964 Clear();
965 break;
966 case eModuleSpecified: {
967 // See if we can find the Module, if so stick it in the SymbolContext.
968 FileSpec module_file_spec(spec_string);
969 ModuleSpec module_spec(module_file_spec);
970 lldb::ModuleSP module_sp =
971 m_target_sp ? m_target_sp->GetImages().FindFirstModule(module_spec)
972 : nullptr;
974 if (module_sp)
975 m_module_sp = module_sp;
976 else
977 m_module_spec.assign(spec_string);
978 } break;
979 case eFileSpecified:
980 // CompUnits can't necessarily be resolved here, since an inlined function
981 // might show up in a number of CompUnits. Instead we just convert to a
982 // FileSpec and store it away.
983 m_file_spec_up = std::make_unique<FileSpec>(spec_string);
985 break;
987 if ((return_value = llvm::to_integer(spec_string, m_start_line)))
989 break;
991 if ((return_value = llvm::to_integer(spec_string, m_end_line)))
993 break;
995 m_function_spec.assign(spec_string);
997 break;
999 Clear();
1000 m_class_name.assign(spec_string);
1002 break;
1004 // Not specified yet...
1005 break;
1006 }
1007
1008 return return_value;
1009}
1010
1012 m_module_spec.clear();
1013 m_file_spec_up.reset();
1014 m_function_spec.clear();
1015 m_class_name.clear();
1016 m_start_line = 0;
1017 m_end_line = 0;
1018 m_address_range_up.reset();
1019
1021}
1022
1025 return true;
1026
1027 // Only compare targets if this specifier has one and it's not the Dummy
1028 // target. Otherwise if a specifier gets made in the dummy target and
1029 // copied over we'll artificially fail the comparision.
1030 if (m_target_sp && !m_target_sp->IsDummyTarget() &&
1031 m_target_sp != sc.target_sp)
1032 return false;
1033
1034 if (m_type & eModuleSpecified) {
1035 if (sc.module_sp) {
1036 if (m_module_sp.get() != nullptr) {
1037 if (m_module_sp.get() != sc.module_sp.get())
1038 return false;
1039 } else {
1040 FileSpec module_file_spec(m_module_spec);
1041 if (!FileSpec::Match(module_file_spec, sc.module_sp->GetFileSpec()))
1042 return false;
1043 }
1044 }
1045 }
1046 if (m_type & eFileSpecified) {
1047 if (m_file_spec_up) {
1048 // If we don't have a block or a comp_unit, then we aren't going to match
1049 // a source file.
1050 if (sc.block == nullptr && sc.comp_unit == nullptr)
1051 return false;
1052
1053 // Check if the block is present, and if so is it inlined:
1054 bool was_inlined = false;
1055 if (sc.block != nullptr) {
1056 const InlineFunctionInfo *inline_info =
1058 if (inline_info != nullptr) {
1059 was_inlined = true;
1061 inline_info->GetDeclaration().GetFile()))
1062 return false;
1063 }
1064 }
1065
1066 // Next check the comp unit, but only if the SymbolContext was not
1067 // inlined.
1068 if (!was_inlined && sc.comp_unit != nullptr) {
1070 return false;
1071 }
1072 }
1073 }
1076 return false;
1077 }
1078
1079 if (m_type & eFunctionSpecified) {
1080 // First check the current block, and if it is inlined, get the inlined
1081 // function name:
1082 bool was_inlined = false;
1083 ConstString func_name(m_function_spec.c_str());
1084
1085 if (sc.block != nullptr) {
1086 const InlineFunctionInfo *inline_info =
1088 if (inline_info != nullptr) {
1089 was_inlined = true;
1090 const Mangled &name = inline_info->GetMangled();
1091 if (!name.NameMatches(func_name))
1092 return false;
1093 }
1094 }
1095 // If it wasn't inlined, check the name in the function or symbol:
1096 if (!was_inlined) {
1097 if (sc.function != nullptr) {
1098 if (!sc.function->GetMangled().NameMatches(func_name))
1099 return false;
1100 } else if (sc.symbol != nullptr) {
1101 if (!sc.symbol->GetMangled().NameMatches(func_name))
1102 return false;
1103 }
1104 }
1105 }
1106
1107 return true;
1108}
1109
1112
1113 } else {
1114 Address match_address(addr, nullptr);
1115 SymbolContext sc;
1116 m_target_sp->GetImages().ResolveSymbolContextForAddress(
1117 match_address, eSymbolContextEverything, sc);
1118 return SymbolContextMatches(sc);
1119 }
1120 return true;
1121}
1122
1124 Stream *s, lldb::DescriptionLevel level) const {
1125 char path_str[PATH_MAX + 1];
1126
1127 if (m_type == eNothingSpecified) {
1128 s->Printf("Nothing specified.\n");
1129 }
1130
1131 if (m_type == eModuleSpecified) {
1132 s->Indent();
1133 if (m_module_sp) {
1134 m_module_sp->GetFileSpec().GetPath(path_str, PATH_MAX);
1135 s->Printf("Module: %s\n", path_str);
1136 } else
1137 s->Printf("Module: %s\n", m_module_spec.c_str());
1138 }
1139
1140 if (m_type == eFileSpecified && m_file_spec_up != nullptr) {
1141 m_file_spec_up->GetPath(path_str, PATH_MAX);
1142 s->Indent();
1143 s->Printf("File: %s", path_str);
1144 if (m_type == eLineStartSpecified) {
1145 s->Printf(" from line %" PRIu64 "", (uint64_t)m_start_line);
1147 s->Printf("to line %" PRIu64 "", (uint64_t)m_end_line);
1148 else
1149 s->Printf("to end");
1150 } else if (m_type == eLineEndSpecified) {
1151 s->Printf(" from start to line %" PRIu64 "", (uint64_t)m_end_line);
1152 }
1153 s->Printf(".\n");
1154 }
1155
1156 if (m_type == eLineStartSpecified) {
1157 s->Indent();
1158 s->Printf("From line %" PRIu64 "", (uint64_t)m_start_line);
1160 s->Printf("to line %" PRIu64 "", (uint64_t)m_end_line);
1161 else
1162 s->Printf("to end");
1163 s->Printf(".\n");
1164 } else if (m_type == eLineEndSpecified) {
1165 s->Printf("From start to line %" PRIu64 ".\n", (uint64_t)m_end_line);
1166 }
1167
1168 if (m_type == eFunctionSpecified) {
1169 s->Indent();
1170 s->Printf("Function: %s.\n", m_function_spec.c_str());
1171 }
1172
1174 s->Indent();
1175 s->Printf("Class name: %s.\n", m_class_name.c_str());
1176 }
1177
1178 if (m_type == eAddressRangeSpecified && m_address_range_up != nullptr) {
1179 s->Indent();
1180 s->PutCString("Address range: ");
1181 m_address_range_up->Dump(s, m_target_sp.get(),
1184 s->PutCString("\n");
1185 }
1186}
1187
1188//
1189// SymbolContextList
1190//
1191
1193
1195
1197 m_symbol_contexts.push_back(sc);
1198}
1199
1201 collection::const_iterator pos, end = sc_list.m_symbol_contexts.end();
1202 for (pos = sc_list.m_symbol_contexts.begin(); pos != end; ++pos)
1203 m_symbol_contexts.push_back(*pos);
1204}
1205
1207 bool merge_symbol_into_function) {
1208 uint32_t unique_sc_add_count = 0;
1209 collection::const_iterator pos, end = sc_list.m_symbol_contexts.end();
1210 for (pos = sc_list.m_symbol_contexts.begin(); pos != end; ++pos) {
1211 if (AppendIfUnique(*pos, merge_symbol_into_function))
1212 ++unique_sc_add_count;
1213 }
1214 return unique_sc_add_count;
1215}
1216
1218 bool merge_symbol_into_function) {
1219 collection::iterator pos, end = m_symbol_contexts.end();
1220 for (pos = m_symbol_contexts.begin(); pos != end; ++pos) {
1221 if (*pos == sc)
1222 return false;
1223 }
1224 if (merge_symbol_into_function && sc.symbol != nullptr &&
1225 sc.comp_unit == nullptr && sc.function == nullptr &&
1226 sc.block == nullptr && !sc.line_entry.IsValid()) {
1227 if (sc.symbol->ValueIsAddress()) {
1228 for (pos = m_symbol_contexts.begin(); pos != end; ++pos) {
1229 // Don't merge symbols into inlined function symbol contexts
1230 if (pos->block && pos->block->GetContainingInlinedBlock())
1231 continue;
1232
1233 if (pos->function) {
1234 if (pos->function->GetAddressRange().GetBaseAddress() ==
1235 sc.symbol->GetAddressRef()) {
1236 // Do we already have a function with this symbol?
1237 if (pos->symbol == sc.symbol)
1238 return false;
1239 if (pos->symbol == nullptr) {
1240 pos->symbol = sc.symbol;
1241 return false;
1242 }
1243 }
1244 }
1245 }
1246 }
1247 }
1248 m_symbol_contexts.push_back(sc);
1249 return true;
1250}
1251
1253
1254void SymbolContextList::Dump(Stream *s, Target *target) const {
1255
1256 *s << this << ": ";
1257 s->Indent();
1258 s->PutCString("SymbolContextList");
1259 s->EOL();
1260 s->IndentMore();
1261
1262 collection::const_iterator pos, end = m_symbol_contexts.end();
1263 for (pos = m_symbol_contexts.begin(); pos != end; ++pos) {
1264 // pos->Dump(s, target);
1265 pos->GetDescription(s, eDescriptionLevelVerbose, target);
1266 }
1267 s->IndentLess();
1268}
1269
1271 if (idx < m_symbol_contexts.size()) {
1272 sc = m_symbol_contexts[idx];
1273 return true;
1274 }
1275 return false;
1276}
1277
1279 if (idx < m_symbol_contexts.size()) {
1280 m_symbol_contexts.erase(m_symbol_contexts.begin() + idx);
1281 return true;
1282 }
1283 return false;
1284}
1285
1286uint32_t SymbolContextList::GetSize() const { return m_symbol_contexts.size(); }
1287
1288bool SymbolContextList::IsEmpty() const { return m_symbol_contexts.empty(); }
1289
1290uint32_t SymbolContextList::NumLineEntriesWithLine(uint32_t line) const {
1291 uint32_t match_count = 0;
1292 const size_t size = m_symbol_contexts.size();
1293 for (size_t idx = 0; idx < size; ++idx) {
1294 if (m_symbol_contexts[idx].line_entry.line == line)
1295 ++match_count;
1296 }
1297 return match_count;
1298}
1299
1301 Target *target) const {
1302 const size_t size = m_symbol_contexts.size();
1303 for (size_t idx = 0; idx < size; ++idx)
1304 m_symbol_contexts[idx].GetDescription(s, level, target);
1305}
1306
1308 const SymbolContextList &rhs) {
1309 const uint32_t size = lhs.GetSize();
1310 if (size != rhs.GetSize())
1311 return false;
1312
1313 SymbolContext lhs_sc;
1314 SymbolContext rhs_sc;
1315 for (uint32_t i = 0; i < size; ++i) {
1316 lhs.GetContextAtIndex(i, lhs_sc);
1317 rhs.GetContextAtIndex(i, rhs_sc);
1318 if (lhs_sc != rhs_sc)
1319 return false;
1320 }
1321 return true;
1322}
1323
1325 const SymbolContextList &rhs) {
1326 return !(lhs == rhs);
1327}
static llvm::raw_ostream & error(Stream &strm)
#define LLDB_LOGF(log,...)
Definition: Log.h:366
A section + offset based address range class.
Definition: AddressRange.h:25
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:211
bool Dump(Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style=Address::DumpStyleInvalid) const
Dump a description of this object to a Stream.
void Clear()
Clear the object's state.
void SetByteSize(lldb::addr_t byte_size)
Set accessor for the byte size of this range.
Definition: AddressRange.h:239
A section + offset based address class.
Definition: Address.h:62
void Clear()
Clear the object's state.
Definition: Address.h:181
@ DumpStyleFileAddress
Display as the file address (if any).
Definition: Address.h:87
@ DumpStyleModuleWithFileAddress
Display as the file address with the module name prepended (if any).
Definition: Address.h:93
@ DumpStyleLoadAddress
Display as the load address (if resolved).
Definition: Address.h:99
bool Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style=DumpStyleInvalid, uint32_t addr_byte_size=UINT32_MAX, bool all_ranges=false, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
Dump a description of this object to a Stream.
Definition: Address.cpp:408
lldb::addr_t GetFileAddress() const
Get the file address.
Definition: Address.cpp:293
lldb::addr_t GetOffset() const
Get the section relative offset value.
Definition: Address.h:329
bool IsValid() const
Check if the object state is valid.
Definition: Address.h:355
bool CalculateSymbolContextLineEntry(LineEntry &line_entry) const
Definition: Address.cpp:914
A class that describes a single lexical block.
Definition: Block.h:41
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
Definition: Block.cpp:136
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
Definition: Block.cpp:208
bool GetRangeAtIndex(uint32_t range_idx, AddressRange &range)
Definition: Block.cpp:303
const InlineFunctionInfo * GetInlinedFunctionInfo() const
Get const accessor for any inlined function information.
Definition: Block.h:276
bool GetRangeContainingAddress(const Address &addr, AddressRange &range)
Definition: Block.cpp:250
Block * GetParent() const
Get the parent block.
Definition: Block.cpp:202
bool GetStartAddress(Address &addr)
Definition: Block.cpp:333
uint32_t GetRangeIndexContainingAddress(const Address &addr)
Definition: Block.cpp:286
A class that describes a compilation unit.
Definition: CompileUnit.h:41
const FileSpec & GetPrimaryFile() const
Return the primary source spec associated with this compile unit.
Definition: CompileUnit.h:230
uint32_t FindLineEntry(uint32_t start_idx, uint32_t line, const FileSpec *file_spec_ptr, bool exact, LineEntry *line_entry)
Find the line entry by line and optional inlined file spec.
void GetDescription(Stream *s, lldb::DescriptionLevel level) const
Definition: CompileUnit.cpp:58
lldb::LanguageType GetLanguage()
Represents a generic declaration context in a program.
A uniqued constant string class.
Definition: ConstString.h:40
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:188
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:197
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
static void ReportWarning(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report warning events.
Definition: Debugger.cpp:1587
uint32_t GetLine() const
Get accessor for the declaration line number.
Definition: Declaration.h:120
uint16_t GetColumn() const
Get accessor for the declaration column number.
Definition: Declaration.h:127
FileSpec & GetFile()
Get accessor for file specification.
Definition: Declaration.h:107
"lldb/Target/ExecutionContextScope.h" Inherit from this if your object can reconstruct its execution ...
A file utility class.
Definition: FileSpec.h:56
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
Definition: FileSpec.cpp:301
void ClearDirectory()
Clear the directory in this object.
Definition: FileSpec.cpp:360
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition: FileSpec.cpp:367
Declaration & GetDeclaration()
Get accessor for the declaration information.
Definition: Function.cpp:53
A class that describes a function.
Definition: Function.h:399
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target)
Definition: Function.cpp:390
const AddressRange & GetAddressRange()
Definition: Function.h:447
ConstString GetName() const
Definition: Function.cpp:693
const Mangled & GetMangled() const
Definition: Function.h:528
Type * GetType()
Get accessor for the type that describes the function return value type, and parameter types.
Definition: Function.cpp:539
lldb::LanguageType GetLanguage() const
Definition: Function.cpp:682
ConstString GetDisplayName() const
Definition: Function.cpp:521
ConstString GetNameNoArguments() const
Definition: Function.cpp:697
Block & GetBlock(bool can_create)
Get accessor for the block list.
Definition: Function.cpp:371
A class that describes information for an inlined function.
Definition: Function.h:125
Declaration & GetCallSite()
Get accessor for the call site declaration information.
Definition: Function.cpp:108
ConstString GetName() const
Definition: Function.cpp:96
Mangled & GetMangled()
Get accessor for the mangled name object.
Definition: Function.cpp:114
static Language * FindPlugin(lldb::LanguageType language)
Definition: Language.cpp:84
A class that handles mangled names.
Definition: Mangled.h:33
bool NameMatches(ConstString name) const
Check if "name" matches either the mangled or demangled name.
Definition: Mangled.h:171
lldb::LanguageType GuessLanguage() const
Try to guess the language from the mangling.
Definition: Mangled.cpp:391
ConstString & GetMangledName()
Mangled name get accessor.
Definition: Mangled.h:145
ConstString GetName(NamePreference preference=ePreferDemangled) const
Best name get accessor.
Definition: Mangled.cpp:335
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Definition: ModuleList.cpp:626
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
Definition: ModuleList.cpp:527
FileSpec & GetPlatformFileSpec()
Definition: ModuleSpec.h:65
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
Definition: Module.cpp:1293
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:44
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
Definition: ObjectFile.h:275
An error handling class.
Definition: Status.h:44
const char * GetData() const
Definition: StreamString.h:45
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
void Format(const char *format, Args &&... args)
Definition: Stream.h:353
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition: Stream.h:401
size_t Indent(llvm::StringRef s="")
Indent the current line in the stream.
Definition: Stream.cpp:157
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:65
size_t PutChar(char ch)
Definition: Stream.cpp:131
void PutCStringColorHighlighted(llvm::StringRef text, std::optional< HighlightSettings > settings=std::nullopt)
Output a C string to the stream with color highlighting.
Definition: Stream.cpp:75
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:155
void IndentLess(unsigned amount=2)
Decrement the current indentation level.
Definition: Stream.cpp:198
void IndentMore(unsigned amount=2)
Increment the current indentation level.
Definition: Stream.cpp:195
Defines a list of symbol context objects.
collection m_symbol_contexts
The list of symbol contexts.
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
uint32_t GetSize() const
Get accessor for a symbol context list size.
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target) const
const_iterator end() const
bool AppendIfUnique(const SymbolContext &sc, bool merge_symbol_into_function)
void Dump(Stream *s, Target *target) const
Dump a description of this object to a Stream.
uint32_t NumLineEntriesWithLine(uint32_t line) const
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
void Clear()
Clear the object's state.
SymbolContextList()
Default constructor.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
virtual Function * CalculateSymbolContextFunction()
virtual CompileUnit * CalculateSymbolContextCompileUnit()
virtual void CalculateSymbolContext(SymbolContext *sc)=0
Reconstruct the object's symbol context into sc.
virtual Block * CalculateSymbolContextBlock()
virtual lldb::ModuleSP CalculateSymbolContextModule()
void GetDescription(Stream *s, lldb::DescriptionLevel level) const
bool AddressMatches(lldb::addr_t addr)
std::unique_ptr< AddressRange > m_address_range_up
std::unique_ptr< FileSpec > m_file_spec_up
bool AddLineSpecification(uint32_t line_no, SpecificationType type)
bool AddSpecification(const char *spec_string, SpecificationType type)
bool SymbolContextMatches(const SymbolContext &sc)
SymbolContextSpecifier(const lldb::TargetSP &target_sp)
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:34
LineEntry GetFunctionStartLineEntry() const
Get the line entry that corresponds to the function.
const Symbol * FindBestGlobalDataSymbol(ConstString name, Status &error)
Find the best global data symbol visible from this context.
lldb::LanguageType GetLanguage() const
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
void Dump(Stream *s, Target *target) const
Dump a description of this object to a Stream.
Function * function
The Function for a given query.
Block * GetFunctionBlock()
Find a block that defines the function represented by this symbol context.
llvm::StringRef GetInstanceVariableName()
Determines the name of the instance variable for the this decl context.
bool GetParentOfInlinedScope(const Address &curr_frame_pc, SymbolContext &next_frame_sc, Address &inlined_frame_addr) const
Find the block containing the inlined block that contains this block.
ConstString GetFunctionName(Mangled::NamePreference preference=Mangled::ePreferDemangled) const
Find a name of the innermost function for the symbol context.
void SortTypeList(TypeMap &type_map, TypeList &type_list) const
Sorts the types in TypeMap according to SymbolContext to TypeList.
Block * block
The Block for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
bool DumpStopContext(Stream *s, ExecutionContextScope *exe_scope, const Address &so_addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, bool show_function_arguments, bool show_function_name, bool show_function_display_name=false, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
Dump the stop context in this object to a Stream.
uint32_t GetResolvedMask() const
void Clear(bool clear_target)
Clear the object's state.
Variable * variable
The global variable matching the given query.
bool GetAddressRange(uint32_t scope, uint32_t range_idx, bool use_inline_block_range, AddressRange &range) const
Get the address range contained within a symbol context.
Symbol * symbol
The Symbol for a given query.
lldb::TargetSP target_sp
The Target for a given query.
LineEntry line_entry
The LineEntry for a given query.
bool GetAddressRangeFromHereToEndLine(uint32_t end_line, AddressRange &range, Status &error)
SymbolContext()
Default constructor.
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:50
bool ValueIsAddress() const
Definition: Symbol.cpp:165
bool IsExternal() const
Definition: Symbol.h:196
bool GetDemangledNameIsSynthesized() const
Definition: Symbol.h:225
Mangled & GetMangled()
Definition: Symbol.h:146
lldb::LanguageType GetLanguage() const
Definition: Symbol.h:138
Address & GetAddressRef()
Definition: Symbol.h:72
ConstString GetReExportedSymbolName() const
Definition: Symbol.cpp:173
void GetDescription(Stream *s, lldb::DescriptionLevel level, Target *target, std::optional< Stream::HighlightSettings > settings=std::nullopt) const
Definition: Symbol.cpp:225
lldb::addr_t GetByteSize() const
Definition: Symbol.cpp:468
ConstString GetName() const
Definition: Symbol.cpp:548
lldb::SymbolType GetType() const
Definition: Symbol.h:168
Address GetAddress() const
Definition: Symbol.h:88
FileSpec GetReExportedSymbolSharedLibrary() const
Definition: Symbol.cpp:187
ConstString GetDisplayName() const
Definition: Symbol.cpp:169
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:981
uint32_t GetSize() const
Definition: TypeList.cpp:60
void ForEach(std::function< bool(const lldb::TypeSP &type_sp)> const &callback) const
Definition: TypeList.cpp:78
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
Definition: TypeList.cpp:66
void Insert(const lldb::TypeSP &type)
Definition: TypeList.cpp:27
bool Empty() const
Definition: TypeMap.cpp:77
bool Remove(const lldb::TypeSP &type_sp)
Definition: TypeMap.cpp:116
void ForEach(std::function< bool(const lldb::TypeSP &type_sp)> const &callback) const
Definition: TypeMap.cpp:100
ConstString GetName()
Definition: Type.cpp:432
void GetDescription(Stream *s, lldb::DescriptionLevel level, bool show_name, ExecutionContextScope *exe_scope)
Definition: Type.cpp:296
void Dump(Stream *s, bool show_context, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
Definition: Type.cpp:364
ConstString GetName() const
Definition: Variable.cpp:73
lldb::LanguageType GetLanguage() const
Definition: Variable.cpp:56
lldb::ValueType GetScope() const
Definition: Variable.h:66
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:331
bool operator!=(const Address &lhs, const Address &rhs)
Definition: Address.cpp:1029
bool operator==(const Address &lhs, const Address &rhs)
Definition: Address.cpp:1023
Definition: SBAddress.h:15
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
@ eDescriptionLevelFull
@ eDescriptionLevelVerbose
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::Type > TypeSP
Definition: lldb-forward.h:456
@ eSymbolTypeUndefined
@ eSymbolTypeVariableType
@ eSymbolTypeObjCMetaClass
@ eSymbolTypeReExported
@ eSymbolTypeObjCClass
@ eSymbolTypeObjectFile
@ eSymbolTypeTrampoline
@ eSymbolTypeResolver
@ eSymbolTypeParam
@ eSymbolTypeSourceFile
@ eSymbolTypeException
@ eSymbolTypeInvalid
@ eSymbolTypeVariable
@ eSymbolTypeAbsolute
@ eSymbolTypeAdditional
When symbols take more than one entry, the extra entries get this type.
@ eSymbolTypeInstrumentation
@ eSymbolTypeLocal
@ eSymbolTypeHeaderFile
@ eSymbolTypeBlock
@ eSymbolTypeCommonBlock
@ eSymbolTypeCompiler
@ eSymbolTypeLineHeader
@ eSymbolTypeObjCIVar
@ eSymbolTypeLineEntry
@ eSymbolTypeRuntime
@ eSymbolTypeScopeBegin
@ eSymbolTypeScopeEnd
uint64_t addr_t
Definition: lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:443
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:370
@ eValueTypeVariableGlobal
globals variable
@ eValueTypeVariableLocal
function local variables
@ eValueTypeVariableArgument
function argument variables
@ eValueTypeVariableStatic
static variable
@ eValueTypeVariableThreadLocal
thread local storage variable
A line table entry class.
Definition: LineEntry.h:21
uint16_t column
The column number of the source line, or zero if there is no column information.
Definition: LineEntry.h:151
void Clear()
Clear the object's state.
Definition: LineEntry.cpp:22
bool Dump(Stream *s, Target *target, bool show_file, Address::DumpStyle style, Address::DumpStyle fallback_style, bool show_range) const
Dump a description of this object to a Stream.
Definition: LineEntry.cpp:60
lldb::SupportFileSP original_file_sp
The original source file, from debug info.
Definition: LineEntry.h:143
bool IsValid() const
Check if a line entry object is valid.
Definition: LineEntry.cpp:35
static int Compare(const LineEntry &lhs, const LineEntry &rhs)
Compare two LineEntry objects.
Definition: LineEntry.cpp:147
AddressRange range
The section offset address range for this line entry.
Definition: LineEntry.h:137
uint32_t line
The source line number, or LLDB_INVALID_LINE_NUMBER if there is no line number information.
Definition: LineEntry.h:147
bool GetDescription(Stream *s, lldb::DescriptionLevel level, CompileUnit *cu, Target *target, bool show_address_only) const
Definition: LineEntry.cpp:95
bool DumpStopContext(Stream *s, bool show_fullpaths) const
Dumps information specific to a process that stops at this line entry to the supplied stream s.
Definition: LineEntry.cpp:39
lldb::SupportFileSP file_sp
The source file, possibly mapped by the target.source-map setting.
Definition: LineEntry.h:140
lldb::user_id_t GetID() const
Get accessor for the user ID.
Definition: UserID.h:47
#define PATH_MAX