LLDB mainline
SearchFilter.cpp
Go to the documentation of this file.
1//===-- SearchFilter.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
12#include "lldb/Core/Module.h"
17#include "lldb/Target/Target.h"
19#include "lldb/Utility/Status.h"
20#include "lldb/Utility/Stream.h"
22
23#include "llvm/ADT/StringRef.h"
24#include "llvm/Support/ErrorHandling.h"
25
26#include <memory>
27#include <mutex>
28#include <string>
29
30#include <cinttypes>
31#include <cstring>
32
33namespace lldb_private {
34class Address;
35}
36namespace lldb_private {
37class Function;
38}
39
40using namespace lldb;
41using namespace lldb_private;
42
43const char *SearchFilter::g_ty_to_name[] = {"Unconstrained", "Exception",
44 "Module", "Modules",
45 "ModulesAndCU", "Unknown"};
46
47const char
49 "ModuleList", "CUList"};
50
51const char *SearchFilter::FilterTyToName(enum FilterTy type) {
52 if (type > LastKnownFilterType)
54
55 return g_ty_to_name[type];
56}
57
59 for (size_t i = 0; i <= LastKnownFilterType; i++) {
60 if (name == g_ty_to_name[i])
61 return (FilterTy)i;
62 }
63 return UnknownFilter;
64}
65
66Searcher::Searcher() = default;
67
68Searcher::~Searcher() = default;
69
71
72SearchFilter::SearchFilter(const TargetSP &target_sp, unsigned char filterType)
73 : m_target_sp(target_sp), SubclassID(filterType) {}
74
76
78 const lldb::TargetSP& target_sp,
79 const StructuredData::Dictionary &filter_dict,
80 Status &error) {
81 SearchFilterSP result_sp;
82 if (!filter_dict.IsValid()) {
84 "Can't deserialize from an invalid data object.");
85 return result_sp;
86 }
87
88 llvm::StringRef subclass_name;
89
90 bool success = filter_dict.GetValueForKeyAsString(
91 GetSerializationSubclassKey(), subclass_name);
92 if (!success) {
93 error = Status::FromErrorString("Filter data missing subclass key");
94 return result_sp;
95 }
96
97 FilterTy filter_type = NameToFilterTy(subclass_name);
98 if (filter_type == UnknownFilter) {
99 error = Status::FromErrorStringWithFormatv("Unknown filter type: {0}.",
100 subclass_name);
101 return result_sp;
102 }
103
104 StructuredData::Dictionary *subclass_options = nullptr;
105 success = filter_dict.GetValueForKeyAsDictionary(
106 GetSerializationSubclassOptionsKey(), subclass_options);
107 if (!success || !subclass_options || !subclass_options->IsValid()) {
108 error =
109 Status::FromErrorString("Filter data missing subclass options key.");
110 return result_sp;
111 }
112
113 switch (filter_type) {
114 case Unconstrained:
116 target_sp, *subclass_options, error);
117 break;
118 case ByModule:
120 target_sp, *subclass_options, error);
121 break;
122 case ByModules:
124 target_sp, *subclass_options, error);
125 break;
126 case ByModulesAndCU:
128 target_sp, *subclass_options, error);
129 break;
130 case Exception:
131 error =
132 Status::FromErrorString("Can't serialize exception breakpoints yet.");
133 break;
134 default:
135 llvm_unreachable("Should never get an uresolvable filter type.");
136 }
137
138 return result_sp;
139}
140
141bool SearchFilter::ModulePasses(const FileSpec &spec) { return true; }
142
143bool SearchFilter::ModulePasses(const ModuleSP &module_sp) { return true; }
144
145bool SearchFilter::AddressPasses(Address &address) { return true; }
146
147bool SearchFilter::CompUnitPasses(FileSpec &fileSpec) { return true; }
148
149bool SearchFilter::CompUnitPasses(CompileUnit &compUnit) { return true; }
150
152 // This is a slightly cheesy job, but since we don't have finer grained
153 // filters yet, just checking that the start address passes is probably
154 // good enough for the base class behavior.
155 Address addr = function.GetAddress();
156 return AddressPasses(addr);
157}
158
159
161 return (lldb::SymbolContextItem)0;
162}
163
165
166void SearchFilter::Dump(Stream *s) const {}
167
169 SearchFilterSP ret_sp = DoCreateCopy();
170 ret_sp->SetTarget(target_sp);
171 return ret_sp;
172}
173
174// Helper functions for serialization.
175
178 if (!options_dict_sp || !options_dict_sp->IsValid())
180
181 auto type_dict_sp = std::make_shared<StructuredData::Dictionary>();
182 type_dict_sp->AddStringItem(GetSerializationSubclassKey(), GetFilterName());
183 type_dict_sp->AddItem(GetSerializationSubclassOptionsKey(), options_dict_sp);
184
185 return type_dict_sp;
186}
187
189 StructuredData::DictionarySP &options_dict_sp, OptionNames name,
190 FileSpecList &file_list) {
191 size_t num_modules = file_list.GetSize();
192
193 // Don't serialize empty lists.
194 if (num_modules == 0)
195 return;
196
197 auto module_array_sp = std::make_shared<StructuredData::Array>();
198 for (size_t i = 0; i < num_modules; i++) {
199 module_array_sp->AddItem(std::make_shared<StructuredData::String>(
200 file_list.GetFileSpecAtIndex(i).GetPath()));
201 }
202 options_dict_sp->AddItem(GetKey(name), module_array_sp);
203}
204
205// UTILITY Functions to help iterate down through the elements of the
206// SymbolContext.
207
209 SymbolContext empty_sc;
210
211 if (!m_target_sp)
212 return;
213 empty_sc.target_sp = m_target_sp;
214
215 if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
216 searcher.SearchCallback(*this, empty_sc, nullptr);
217 return;
218 }
219
220 DoModuleIteration(empty_sc, searcher);
221}
222
224 SymbolContext empty_sc;
225
226 if (!m_target_sp)
227 return;
228 empty_sc.target_sp = m_target_sp;
229
230 if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
231 searcher.SearchCallback(*this, empty_sc, nullptr);
232 return;
233 }
234
235 for (ModuleSP module_sp : modules.Modules()) {
236 if (!ModulePasses(module_sp))
237 continue;
238 if (DoModuleIteration(module_sp, searcher) == Searcher::eCallbackReturnStop)
239 return;
240 }
241}
242
245 Searcher &searcher) {
246 SymbolContext matchingContext(m_target_sp, module_sp);
247 return DoModuleIteration(matchingContext, searcher);
248}
249
252 Searcher &searcher) {
253 if (searcher.GetDepth() < lldb::eSearchDepthModule)
255
256 if (context.module_sp) {
257 if (searcher.GetDepth() != lldb::eSearchDepthModule)
258 return DoCUIteration(context.module_sp, context, searcher);
259
260 SymbolContext matchingContext(context.module_sp.get());
261 searcher.SearchCallback(*this, matchingContext, nullptr);
263 }
264
265 ModuleList module_list = m_target_sp->GetImages();
266 // Since we're iterating over a copy, no need to do any locking.
267 for (ModuleSP module_sp : module_list.ModulesNoLocking()) {
268 // If this is the last level supplied, then call the callback directly,
269 // otherwise descend.
270 if (!ModulePasses(module_sp))
271 continue;
272
273 if (searcher.GetDepth() == lldb::eSearchDepthModule) {
274 SymbolContext matchingContext(m_target_sp, module_sp);
275
276 Searcher::CallbackReturn shouldContinue =
277 searcher.SearchCallback(*this, matchingContext, nullptr);
278 if (shouldContinue == Searcher::eCallbackReturnStop ||
279 shouldContinue == Searcher::eCallbackReturnPop)
280 return shouldContinue;
281 } else {
282 Searcher::CallbackReturn shouldContinue =
283 DoCUIteration(module_sp, context, searcher);
284 if (shouldContinue == Searcher::eCallbackReturnStop)
285 return shouldContinue;
286 else if (shouldContinue == Searcher::eCallbackReturnPop)
287 continue;
288 }
289 }
290
292}
293
296 const SymbolContext &context, Searcher &searcher) {
297 Searcher::CallbackReturn shouldContinue;
298 if (context.comp_unit != nullptr) {
299 if (CompUnitPasses(*context.comp_unit)) {
300 SymbolContext matchingContext(m_target_sp, module_sp, context.comp_unit);
301 return searcher.SearchCallback(*this, matchingContext, nullptr);
302 }
304 }
305
306 const size_t num_comp_units = module_sp->GetNumCompileUnits();
307 for (size_t i = 0; i < num_comp_units; i++) {
308 CompUnitSP cu_sp(module_sp->GetCompileUnitAtIndex(i));
309 if (!cu_sp)
310 continue;
311 if (!CompUnitPasses(*(cu_sp.get())))
312 continue;
313
314 if (searcher.GetDepth() == lldb::eSearchDepthCompUnit) {
315 SymbolContext matchingContext(m_target_sp, module_sp, cu_sp.get());
316
317 shouldContinue = searcher.SearchCallback(*this, matchingContext, nullptr);
318
319 if (shouldContinue == Searcher::eCallbackReturnPop)
321 else if (shouldContinue == Searcher::eCallbackReturnStop)
322 return shouldContinue;
323 continue;
324 }
325
326 // First make sure this compile unit's functions are parsed
327 // since CompUnit::ForeachFunction only iterates over already
328 // parsed functions.
329 SymbolFile *sym_file = module_sp->GetSymbolFile();
330 if (!sym_file)
331 continue;
332 if (!sym_file->ParseFunctions(*cu_sp))
333 continue;
334 // If we got any functions, use ForeachFunction to do the iteration.
335 cu_sp->ForeachFunction([&](const FunctionSP &func_sp) {
336 if (!FunctionPasses(*func_sp.get()))
337 return false; // Didn't pass the filter, just keep going.
338 if (searcher.GetDepth() == lldb::eSearchDepthFunction) {
339 SymbolContext matchingContext(m_target_sp, module_sp, cu_sp.get(),
340 func_sp.get());
341 shouldContinue =
342 searcher.SearchCallback(*this, matchingContext, nullptr);
343 } else {
344 shouldContinue = DoFunctionIteration(func_sp.get(), context, searcher);
345 }
346 return shouldContinue != Searcher::eCallbackReturnContinue;
347 });
348 }
350}
351
353 Function *function, const SymbolContext &context, Searcher &searcher) {
354 // FIXME: Implement...
356}
357
358// SearchFilterForUnconstrainedSearches:
359// Selects a shared library matching a given file spec, consulting the targets
360// "black list".
362 const lldb::TargetSP& target_sp,
363 const StructuredData::Dictionary &data_dict,
364 Status &error) {
365 // No options for an unconstrained search.
366 return std::make_shared<SearchFilterForUnconstrainedSearches>(target_sp);
367}
368
371 // The options dictionary is an empty dictionary:
372 auto result_sp = std::make_shared<StructuredData::Dictionary>();
373 return WrapOptionsDict(result_sp);
374}
375
377 const FileSpec &module_spec) {
378 return !m_target_sp->ModuleIsExcludedForUnconstrainedSearches(module_spec);
379}
380
382 const lldb::ModuleSP &module_sp) {
383 if (!module_sp)
384 return true;
385 else if (m_target_sp->ModuleIsExcludedForUnconstrainedSearches(module_sp))
386 return false;
387 return true;
388}
389
391 return std::make_shared<SearchFilterForUnconstrainedSearches>(*this);
392}
393
394// SearchFilterByModule:
395// Selects a shared library matching a given file spec
396
398 const FileSpec &module)
399 : SearchFilter(target_sp, FilterTy::ByModule), m_module_spec(module) {}
400
402
404 return (module_sp &&
405 FileSpec::Match(m_module_spec, module_sp->GetFileSpec()));
406}
407
411
413 // FIXME: Not yet implemented
414 return true;
415}
416
418 if (!m_target_sp)
419 return;
420
421 if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
422 SymbolContext empty_sc;
423 empty_sc.target_sp = m_target_sp;
424 searcher.SearchCallback(*this, empty_sc, nullptr);
425 }
426
427 ModuleList module_list = m_target_sp->GetImages();
428 // Since we're iterating over a copy, no need to do any locking.
429 for (ModuleSP module_sp : module_list.ModulesNoLocking()) {
430 if (FileSpec::Match(m_module_spec, module_sp->GetFileSpec())) {
431 SymbolContext matchingContext(m_target_sp, module_sp);
432 Searcher::CallbackReturn shouldContinue;
433
434 shouldContinue = DoModuleIteration(matchingContext, searcher);
435 if (shouldContinue == Searcher::eCallbackReturnStop)
436 return;
437 }
438 }
439}
440
442 s->PutCString(", module = ");
443 s->PutCString(m_module_spec.GetFilename().AsCString("<Unknown>"));
444}
445
447 return eSymbolContextModule;
448}
449
451
453 return std::make_shared<SearchFilterByModule>(*this);
454}
455
457 const lldb::TargetSP& target_sp,
458 const StructuredData::Dictionary &data_dict,
459 Status &error) {
460 StructuredData::Array *modules_array;
461 bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
462 modules_array);
463 if (!success) {
465 "SFBM::CFSD: Could not find the module list key.");
466 return nullptr;
467 }
468
469 size_t num_modules = modules_array->GetSize();
470 if (num_modules > 1) {
472 "SFBM::CFSD: Only one modules allowed for SearchFilterByModule.");
473 return nullptr;
474 }
475
476 std::optional<llvm::StringRef> maybe_module =
477 modules_array->GetItemAtIndexAsString(0);
478 if (!maybe_module) {
479 error =
480 Status::FromErrorString("SFBM::CFSD: filter module item not a string.");
481 return nullptr;
482 }
483 FileSpec module_spec(*maybe_module);
484
485 return std::make_shared<SearchFilterByModule>(target_sp, module_spec);
486}
487
489 auto options_dict_sp = std::make_shared<StructuredData::Dictionary>();
490 auto module_array_sp = std::make_shared<StructuredData::Array>();
491 module_array_sp->AddItem(
492 std::make_shared<StructuredData::String>(m_module_spec.GetPath()));
493 options_dict_sp->AddItem(GetKey(OptionNames::ModList), module_array_sp);
494 return WrapOptionsDict(options_dict_sp);
495}
496
497// SearchFilterByModuleList:
498// Selects a shared library matching a given file spec
499
501 const lldb::TargetSP &target_sp, const FileSpecList &module_list)
502 : SearchFilter(target_sp, FilterTy::ByModules),
503 m_module_spec_list(module_list) {}
504
506 const lldb::TargetSP &target_sp, const FileSpecList &module_list,
507 enum FilterTy filter_ty)
508 : SearchFilter(target_sp, filter_ty), m_module_spec_list(module_list) {}
509
511
513 if (m_module_spec_list.GetSize() == 0)
514 return true;
515
516 return module_sp && m_module_spec_list.FindFileIndex(
517 0, module_sp->GetFileSpec(), false) != UINT32_MAX;
518}
519
521 if (m_module_spec_list.GetSize() == 0)
522 return true;
523
524 return m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX;
525}
526
528 // FIXME: Not yet implemented
529 return true;
530}
531
533 if (!m_target_sp)
534 return;
535
536 if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
537 SymbolContext empty_sc;
538 empty_sc.target_sp = m_target_sp;
539 searcher.SearchCallback(*this, empty_sc, nullptr);
540 }
541
542 // If the module file spec is a full path, then we can just find the one
543 // filespec that passes. Otherwise, we need to go through all modules and
544 // find the ones that match the file name.
545 ModuleList module_list = m_target_sp->GetImages();
546 // Since we're iterating over a copy, no need to do any locking.
547 for (ModuleSP module_sp : module_list.ModulesNoLocking()) {
548 if (m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec(), false) ==
550 continue;
551 SymbolContext matchingContext(m_target_sp, module_sp);
552 Searcher::CallbackReturn shouldContinue;
553
554 shouldContinue = DoModuleIteration(matchingContext, searcher);
555 if (shouldContinue == Searcher::eCallbackReturnStop)
556 return;
557 }
558}
559
561 size_t num_modules = m_module_spec_list.GetSize();
562 if (num_modules == 1) {
563 s->Printf(", module = ");
564 s->PutCString(
565 m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString(
566 "<Unknown>"));
567 return;
568 }
569
570 s->Printf(", modules(%" PRIu64 ") = ", (uint64_t)num_modules);
571 for (size_t i = 0; i < num_modules; i++) {
572 s->PutCString(
573 m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString(
574 "<Unknown>"));
575 if (i != num_modules - 1)
576 s->PutCString(", ");
577 }
578}
579
581 return eSymbolContextModule;
582}
583
585
587 return std::make_shared<SearchFilterByModuleList>(*this);
588}
589
591 const lldb::TargetSP& target_sp,
592 const StructuredData::Dictionary &data_dict,
593 Status &error) {
594 StructuredData::Array *modules_array;
595 bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
596 modules_array);
597
598 if (!success)
599 return std::make_shared<SearchFilterByModuleList>(target_sp,
600 FileSpecList{});
601 FileSpecList modules;
602 size_t num_modules = modules_array->GetSize();
603 for (size_t i = 0; i < num_modules; i++) {
604 std::optional<llvm::StringRef> maybe_module =
605 modules_array->GetItemAtIndexAsString(i);
606 if (!maybe_module) {
608 "SFBM::CFSD: filter module item %zu not a string.", i);
609 return nullptr;
610 }
611 modules.EmplaceBack(*maybe_module);
612 }
613 return std::make_shared<SearchFilterByModuleList>(target_sp, modules);
614}
615
621
623 auto options_dict_sp = std::make_shared<StructuredData::Dictionary>();
624 SerializeUnwrapped(options_dict_sp);
625 return WrapOptionsDict(options_dict_sp);
626}
627
628// SearchFilterByModuleListAndCU:
629// Selects a shared library matching a given file spec
630
632 const lldb::TargetSP &target_sp, const FileSpecList &module_list,
633 const FileSpecList &cu_list)
634 : SearchFilterByModuleList(target_sp, module_list,
636 m_cu_spec_list(cu_list) {}
637
639
641 const lldb::TargetSP& target_sp,
642 const StructuredData::Dictionary &data_dict,
643 Status &error) {
644 StructuredData::Array *modules_array = nullptr;
645 SearchFilterSP result_sp;
646 bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
647 modules_array);
648 FileSpecList modules;
649 if (success) {
650 size_t num_modules = modules_array->GetSize();
651 for (size_t i = 0; i < num_modules; i++) {
652 std::optional<llvm::StringRef> maybe_module =
653 modules_array->GetItemAtIndexAsString(i);
654 if (!maybe_module) {
656 "SFBM::CFSD: filter module item %zu not a string.", i);
657 return result_sp;
658 }
659 modules.EmplaceBack(*maybe_module);
660 }
661 }
662
663 StructuredData::Array *cus_array = nullptr;
664 success =
665 data_dict.GetValueForKeyAsArray(GetKey(OptionNames::CUList), cus_array);
666 if (!success) {
667 error =
668 Status::FromErrorString("SFBM::CFSD: Could not find the CU list key.");
669 return result_sp;
670 }
671
672 size_t num_cus = cus_array->GetSize();
673 FileSpecList cus;
674 for (size_t i = 0; i < num_cus; i++) {
675 std::optional<llvm::StringRef> maybe_cu =
676 cus_array->GetItemAtIndexAsString(i);
677 if (!maybe_cu) {
679 "SFBM::CFSD: filter CU item %zu not a string.", i);
680 return nullptr;
681 }
682 cus.EmplaceBack(*maybe_cu);
683 }
684
685 return std::make_shared<SearchFilterByModuleListAndCU>(
686 target_sp, modules, cus);
687}
688
691 auto options_dict_sp = std::make_shared<StructuredData::Dictionary>();
694 return WrapOptionsDict(options_dict_sp);
695}
696
698 SymbolContext sym_ctx;
699 address.CalculateSymbolContext(&sym_ctx, eSymbolContextEverything);
700 if (!sym_ctx.comp_unit) {
701 if (m_cu_spec_list.GetSize() != 0)
702 return false; // Has no comp_unit so can't pass the file check.
703 }
704 FileSpec cu_spec;
705 if (sym_ctx.comp_unit)
706 cu_spec = sym_ctx.comp_unit->GetPrimaryFile();
707 if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) == UINT32_MAX)
708 return false; // Fails the file check
710}
711
713 return m_cu_spec_list.FindFileIndex(0, fileSpec, false) != UINT32_MAX;
714}
715
717 bool in_cu_list = m_cu_spec_list.FindFileIndex(0, compUnit.GetPrimaryFile(),
718 false) != UINT32_MAX;
719 if (!in_cu_list)
720 return false;
721
722 ModuleSP module_sp(compUnit.GetModule());
723 if (!module_sp)
724 return true;
725
727}
728
730 if (!m_target_sp)
731 return;
732
733 if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
734 SymbolContext empty_sc;
735 empty_sc.target_sp = m_target_sp;
736 searcher.SearchCallback(*this, empty_sc, nullptr);
737 }
738
739 // If the module file spec is a full path, then we can just find the one
740 // filespec that passes. Otherwise, we need to go through all modules and
741 // find the ones that match the file name.
742
743 ModuleList matching_modules;
744
745 bool no_modules_in_filter = m_module_spec_list.GetSize() == 0;
746 ModuleList module_list = m_target_sp->GetImages();
747 // Since we're iterating over a copy, no need to do any locking.
748 for (ModuleSP module_sp : module_list.ModulesNoLocking()) {
749 if (!no_modules_in_filter &&
750 m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec(), false) ==
752 continue;
753
754 SymbolContext matchingContext(m_target_sp, module_sp);
755 Searcher::CallbackReturn shouldContinue;
756
757 if (searcher.GetDepth() == lldb::eSearchDepthModule) {
758 shouldContinue = DoModuleIteration(matchingContext, searcher);
759 if (shouldContinue == Searcher::eCallbackReturnStop)
760 return;
761 continue;
762 }
763
764 const size_t num_cu = module_sp->GetNumCompileUnits();
765 for (size_t cu_idx = 0; cu_idx < num_cu; cu_idx++) {
766 CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(cu_idx);
767 matchingContext.comp_unit = cu_sp.get();
768 if (!matchingContext.comp_unit)
769 continue;
770 if (m_cu_spec_list.FindFileIndex(
771 0, matchingContext.comp_unit->GetPrimaryFile(), false) ==
773 continue;
774 shouldContinue = DoCUIteration(module_sp, matchingContext, searcher);
775 if (shouldContinue == Searcher::eCallbackReturnStop)
776 return;
777 }
778 }
779}
780
782 size_t num_modules = m_module_spec_list.GetSize();
783 if (num_modules == 1) {
784 s->Printf(", module = ");
785 s->PutCString(
786 m_module_spec_list.GetFileSpecAtIndex(0).GetFilename().AsCString(
787 "<Unknown>"));
788 } else if (num_modules > 0) {
789 s->Printf(", modules(%" PRIu64 ") = ", static_cast<uint64_t>(num_modules));
790 for (size_t i = 0; i < num_modules; i++) {
791 s->PutCString(
792 m_module_spec_list.GetFileSpecAtIndex(i).GetFilename().AsCString(
793 "<Unknown>"));
794 if (i != num_modules - 1)
795 s->PutCString(", ");
796 }
797 }
798}
799
801 return eSymbolContextModule | eSymbolContextCompUnit;
802}
803
805
807 return std::make_shared<SearchFilterByModuleListAndCU>(*this);
808}
static llvm::raw_ostream & error(Stream &strm)
A section + offset based address class.
Definition Address.h:62
uint32_t CalculateSymbolContext(SymbolContext *sc, lldb::SymbolContextItem resolve_scope=lldb::eSymbolContextEverything) const
Reconstruct a symbol context from an address.
Definition Address.cpp:819
A class that describes a compilation unit.
Definition CompileUnit.h:43
const FileSpec & GetPrimaryFile() const
Return the primary source spec associated with this compile unit.
A file collection class.
const FileSpec & GetFileSpecAtIndex(size_t idx) const
Get file at index.
void EmplaceBack(Args &&...args)
Inserts a new FileSpec into the FileSpecList constructed in-place with the given arguments.
size_t GetSize() const
Get the number of files in the file list.
A file utility class.
Definition FileSpec.h:57
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
Definition FileSpec.cpp:301
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:374
A class that describes a function.
Definition Function.h:400
const Address & GetAddress() const
Return the address of the function (its entry point).
Definition Function.h:453
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
A collection class for Module objects.
Definition ModuleList.h:125
ModuleIterableNoLocking ModulesNoLocking() const
Definition ModuleList.h:571
ModuleIterable Modules() const
Definition ModuleList.h:565
StructuredData::ObjectSP SerializeToStructuredData() override
lldb::SearchFilterSP DoCreateCopy() override
bool AddressPasses(Address &address) override
Call this method with a Address to see if address passes the filter.
void Dump(Stream *s) const override
Standard "Dump" method. At present it does nothing.
bool CompUnitPasses(FileSpec &fileSpec) override
Call this method with a FileSpec to see if file spec passes the filter as the name of a compilation u...
void Search(Searcher &searcher) override
Call this method to do the search using the Searcher.
void GetDescription(Stream *s) override
Prints a canonical description for the search filter to the stream s.
static lldb::SearchFilterSP CreateFromStructuredData(const lldb::TargetSP &target_sp, const StructuredData::Dictionary &data_dict, Status &error)
SearchFilterByModuleListAndCU(const lldb::TargetSP &targetSP, const FileSpecList &module_list, const FileSpecList &cu_list)
The basic constructor takes a Target, which gives the space to search, and the module list to restric...
uint32_t GetFilterRequiredItems() override
This determines which items are REQUIRED for the filter to pass.
bool AddressPasses(Address &address) override
Call this method with a Address to see if address passes the filter.
void Dump(Stream *s) const override
Standard "Dump" method. At present it does nothing.
void GetDescription(Stream *s) override
Prints a canonical description for the search filter to the stream s.
uint32_t GetFilterRequiredItems() override
This determines which items are REQUIRED for the filter to pass.
void SerializeUnwrapped(StructuredData::DictionarySP &options_dict_sp)
lldb::SearchFilterSP DoCreateCopy() override
void Search(Searcher &searcher) override
Call this method to do the search using the Searcher.
bool ModulePasses(const lldb::ModuleSP &module_sp) override
Call this method with a Module to see if that module passes the filter.
StructuredData::ObjectSP SerializeToStructuredData() override
SearchFilterByModuleList(const lldb::TargetSP &targetSP, const FileSpecList &module_list)
The basic constructor takes a Target, which gives the space to search, and the module list to restric...
static lldb::SearchFilterSP CreateFromStructuredData(const lldb::TargetSP &target_sp, const StructuredData::Dictionary &data_dict, Status &error)
bool AddressPasses(Address &address) override
Call this method with a Address to see if address passes the filter.
StructuredData::ObjectSP SerializeToStructuredData() override
bool ModulePasses(const lldb::ModuleSP &module_sp) override
Call this method with a Module to see if that module passes the filter.
lldb::SearchFilterSP DoCreateCopy() override
static lldb::SearchFilterSP CreateFromStructuredData(const lldb::TargetSP &target_sp, const StructuredData::Dictionary &data_dict, Status &error)
void Search(Searcher &searcher) override
Call this method to do the search using the Searcher.
uint32_t GetFilterRequiredItems() override
This determines which items are REQUIRED for the filter to pass.
void Dump(Stream *s) const override
Standard "Dump" method. At present it does nothing.
void GetDescription(Stream *s) override
Prints a canonical description for the search filter to the stream s.
SearchFilterByModule(const lldb::TargetSP &targetSP, const FileSpec &module)
The basic constructor takes a Target, which gives the space to search, and the module to restrict the...
static lldb::SearchFilterSP CreateFromStructuredData(const lldb::TargetSP &target_sp, const StructuredData::Dictionary &data_dict, Status &error)
StructuredData::ObjectSP SerializeToStructuredData() override
bool ModulePasses(const FileSpec &module_spec) override
Call this method with a file spec to see if that spec passes the filter.
void SerializeFileSpecList(StructuredData::DictionarySP &options_dict_sp, OptionNames name, FileSpecList &file_list)
virtual void SearchInModuleList(Searcher &searcher, ModuleList &modules)
Call this method to do the search using the Searcher in the module list modules.
StructuredData::DictionarySP WrapOptionsDict(StructuredData::DictionarySP options_dict_sp)
virtual bool AddressPasses(Address &addr)
Call this method with a Address to see if address passes the filter.
static const char * GetKey(enum OptionNames enum_value)
static FilterTy NameToFilterTy(llvm::StringRef name)
static const char * FilterTyToName(enum FilterTy)
Searcher::CallbackReturn DoFunctionIteration(Function *function, const SymbolContext &context, Searcher &searcher)
static const char * GetSerializationSubclassKey()
virtual lldb::SearchFilterSP DoCreateCopy()=0
Searcher::CallbackReturn DoModuleIteration(const SymbolContext &context, Searcher &searcher)
virtual bool CompUnitPasses(FileSpec &fileSpec)
Call this method with a FileSpec to see if file spec passes the filter as the name of a compilation u...
virtual bool ModulePasses(const FileSpec &spec)
Call this method with a file spec to see if that spec passes the filter.
virtual void GetDescription(Stream *s)
Prints a canonical description for the search filter to the stream s.
lldb::SearchFilterSP CreateCopy(lldb::TargetSP &target_sp)
virtual uint32_t GetFilterRequiredItems()
This determines which items are REQUIRED for the filter to pass.
static lldb::SearchFilterSP CreateFromStructuredData(const lldb::TargetSP &target_sp, const StructuredData::Dictionary &data_dict, Status &error)
SearchFilter(const lldb::TargetSP &target_sp)
The basic constructor takes a Target, which gives the space to search.
static const char * GetSerializationSubclassOptionsKey()
Searcher::CallbackReturn DoCUIteration(const lldb::ModuleSP &module_sp, const SymbolContext &context, Searcher &searcher)
static const char * g_ty_to_name[LastKnownFilterType+2]
virtual bool FunctionPasses(Function &function)
Call this method with a Function to see if function passes the filter.
virtual void Dump(Stream *s) const
Standard "Dump" method. At present it does nothing.
static const char * g_option_names[LastOptionName]
virtual void Search(Searcher &searcher)
Call this method to do the search using the Searcher.
General Outline: Provides the callback and search depth for the SearchFilter search.
virtual CallbackReturn SearchCallback(SearchFilter &filter, SymbolContext &context, Address *addr)=0
virtual lldb::SearchDepth GetDepth()=0
virtual void GetDescription(Stream *s)
Prints a canonical description for the searcher to the stream s.
An error handling class.
Definition Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition Status.h:151
A stream class that can stream formatted output to a file.
Definition Stream.h:28
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
std::optional< llvm::StringRef > GetItemAtIndexAsString(size_t idx) const
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result) const
bool GetValueForKeyAsArray(llvm::StringRef key, Array *&result) const
bool GetValueForKeyAsDictionary(llvm::StringRef key, Dictionary *&result) const
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
lldb::ModuleSP module_sp
The Module for a given query.
CompileUnit * comp_unit
The CompileUnit for a given query.
lldb::TargetSP target_sp
The Target for a given query.
Provides public interface for all SymbolFiles.
Definition SymbolFile.h:51
virtual size_t ParseFunctions(CompileUnit &comp_unit)=0
#define UINT32_MAX
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Function > FunctionSP
std::shared_ptr< lldb_private::SearchFilter > SearchFilterSP
@ eSearchDepthFunction
@ eSearchDepthCompUnit
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::CompileUnit > CompUnitSP