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()) {
83 error.SetErrorString("Can't deserialize from an invalid data object.");
84 return result_sp;
85 }
86
87 llvm::StringRef subclass_name;
88
89 bool success = filter_dict.GetValueForKeyAsString(
90 GetSerializationSubclassKey(), subclass_name);
91 if (!success) {
92 error.SetErrorString("Filter data missing subclass key");
93 return result_sp;
94 }
95
96 FilterTy filter_type = NameToFilterTy(subclass_name);
97 if (filter_type == UnknownFilter) {
98 error.SetErrorStringWithFormatv("Unknown filter type: {0}.", subclass_name);
99 return result_sp;
100 }
101
102 StructuredData::Dictionary *subclass_options = nullptr;
103 success = filter_dict.GetValueForKeyAsDictionary(
104 GetSerializationSubclassOptionsKey(), subclass_options);
105 if (!success || !subclass_options || !subclass_options->IsValid()) {
106 error.SetErrorString("Filter data missing subclass options key.");
107 return result_sp;
108 }
109
110 switch (filter_type) {
111 case Unconstrained:
113 target_sp, *subclass_options, error);
114 break;
115 case ByModule:
117 target_sp, *subclass_options, error);
118 break;
119 case ByModules:
121 target_sp, *subclass_options, error);
122 break;
123 case ByModulesAndCU:
125 target_sp, *subclass_options, error);
126 break;
127 case Exception:
128 error.SetErrorString("Can't serialize exception breakpoints yet.");
129 break;
130 default:
131 llvm_unreachable("Should never get an uresolvable filter type.");
132 }
133
134 return result_sp;
135}
136
137bool SearchFilter::ModulePasses(const FileSpec &spec) { return true; }
138
139bool SearchFilter::ModulePasses(const ModuleSP &module_sp) { return true; }
140
141bool SearchFilter::AddressPasses(Address &address) { return true; }
142
143bool SearchFilter::CompUnitPasses(FileSpec &fileSpec) { return true; }
144
145bool SearchFilter::CompUnitPasses(CompileUnit &compUnit) { return true; }
146
148 // This is a slightly cheesy job, but since we don't have finer grained
149 // filters yet, just checking that the start address passes is probably
150 // good enough for the base class behavior.
151 Address addr = function.GetAddressRange().GetBaseAddress();
152 return AddressPasses(addr);
153}
154
155
157 return (lldb::SymbolContextItem)0;
158}
159
161
162void SearchFilter::Dump(Stream *s) const {}
163
165 SearchFilterSP ret_sp = DoCreateCopy();
166 ret_sp->SetTarget(target_sp);
167 return ret_sp;
168}
169
170// Helper functions for serialization.
171
174 if (!options_dict_sp || !options_dict_sp->IsValid())
176
177 auto type_dict_sp = std::make_shared<StructuredData::Dictionary>();
178 type_dict_sp->AddStringItem(GetSerializationSubclassKey(), GetFilterName());
179 type_dict_sp->AddItem(GetSerializationSubclassOptionsKey(), options_dict_sp);
180
181 return type_dict_sp;
182}
183
185 StructuredData::DictionarySP &options_dict_sp, OptionNames name,
186 FileSpecList &file_list) {
187 size_t num_modules = file_list.GetSize();
188
189 // Don't serialize empty lists.
190 if (num_modules == 0)
191 return;
192
193 auto module_array_sp = std::make_shared<StructuredData::Array>();
194 for (size_t i = 0; i < num_modules; i++) {
195 module_array_sp->AddItem(std::make_shared<StructuredData::String>(
196 file_list.GetFileSpecAtIndex(i).GetPath()));
197 }
198 options_dict_sp->AddItem(GetKey(name), module_array_sp);
199}
200
201// UTILITY Functions to help iterate down through the elements of the
202// SymbolContext.
203
205 SymbolContext empty_sc;
206
207 if (!m_target_sp)
208 return;
209 empty_sc.target_sp = m_target_sp;
210
211 if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
212 searcher.SearchCallback(*this, empty_sc, nullptr);
213 return;
214 }
215
216 DoModuleIteration(empty_sc, searcher);
217}
218
220 SymbolContext empty_sc;
221
222 if (!m_target_sp)
223 return;
224 empty_sc.target_sp = m_target_sp;
225
226 if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
227 searcher.SearchCallback(*this, empty_sc, nullptr);
228 return;
229 }
230
231 for (ModuleSP module_sp : modules.Modules()) {
232 if (!ModulePasses(module_sp))
233 continue;
234 if (DoModuleIteration(module_sp, searcher) == Searcher::eCallbackReturnStop)
235 return;
236 }
237}
238
241 Searcher &searcher) {
242 SymbolContext matchingContext(m_target_sp, module_sp);
243 return DoModuleIteration(matchingContext, searcher);
244}
245
248 Searcher &searcher) {
249 if (searcher.GetDepth() < lldb::eSearchDepthModule)
251
252 if (context.module_sp) {
253 if (searcher.GetDepth() != lldb::eSearchDepthModule)
254 return DoCUIteration(context.module_sp, context, searcher);
255
256 SymbolContext matchingContext(context.module_sp.get());
257 searcher.SearchCallback(*this, matchingContext, nullptr);
259 }
260
261 for (ModuleSP module_sp : m_target_sp->GetImages().Modules()) {
262 // If this is the last level supplied, then call the callback directly,
263 // otherwise descend.
264 if (!ModulePasses(module_sp))
265 continue;
266
267 if (searcher.GetDepth() == lldb::eSearchDepthModule) {
268 SymbolContext matchingContext(m_target_sp, module_sp);
269
270 Searcher::CallbackReturn shouldContinue =
271 searcher.SearchCallback(*this, matchingContext, nullptr);
272 if (shouldContinue == Searcher::eCallbackReturnStop ||
273 shouldContinue == Searcher::eCallbackReturnPop)
274 return shouldContinue;
275 } else {
276 Searcher::CallbackReturn shouldContinue =
277 DoCUIteration(module_sp, context, searcher);
278 if (shouldContinue == Searcher::eCallbackReturnStop)
279 return shouldContinue;
280 else if (shouldContinue == Searcher::eCallbackReturnPop)
281 continue;
282 }
283 }
284
286}
287
290 const SymbolContext &context, Searcher &searcher) {
291 Searcher::CallbackReturn shouldContinue;
292 if (context.comp_unit != nullptr) {
293 if (CompUnitPasses(*context.comp_unit)) {
294 SymbolContext matchingContext(m_target_sp, module_sp, context.comp_unit);
295 return searcher.SearchCallback(*this, matchingContext, nullptr);
296 }
298 }
299
300 const size_t num_comp_units = module_sp->GetNumCompileUnits();
301 for (size_t i = 0; i < num_comp_units; i++) {
302 CompUnitSP cu_sp(module_sp->GetCompileUnitAtIndex(i));
303 if (!cu_sp)
304 continue;
305 if (!CompUnitPasses(*(cu_sp.get())))
306 continue;
307
308 if (searcher.GetDepth() == lldb::eSearchDepthCompUnit) {
309 SymbolContext matchingContext(m_target_sp, module_sp, cu_sp.get());
310
311 shouldContinue = searcher.SearchCallback(*this, matchingContext, nullptr);
312
313 if (shouldContinue == Searcher::eCallbackReturnPop)
315 else if (shouldContinue == Searcher::eCallbackReturnStop)
316 return shouldContinue;
317 continue;
318 }
319
320 // First make sure this compile unit's functions are parsed
321 // since CompUnit::ForeachFunction only iterates over already
322 // parsed functions.
323 SymbolFile *sym_file = module_sp->GetSymbolFile();
324 if (!sym_file)
325 continue;
326 if (!sym_file->ParseFunctions(*cu_sp))
327 continue;
328 // If we got any functions, use ForeachFunction to do the iteration.
329 cu_sp->ForeachFunction([&](const FunctionSP &func_sp) {
330 if (!FunctionPasses(*func_sp.get()))
331 return false; // Didn't pass the filter, just keep going.
332 if (searcher.GetDepth() == lldb::eSearchDepthFunction) {
333 SymbolContext matchingContext(m_target_sp, module_sp, cu_sp.get(),
334 func_sp.get());
335 shouldContinue =
336 searcher.SearchCallback(*this, matchingContext, nullptr);
337 } else {
338 shouldContinue = DoFunctionIteration(func_sp.get(), context, searcher);
339 }
340 return shouldContinue != Searcher::eCallbackReturnContinue;
341 });
342 }
344}
345
347 Function *function, const SymbolContext &context, Searcher &searcher) {
348 // FIXME: Implement...
350}
351
352// SearchFilterForUnconstrainedSearches:
353// Selects a shared library matching a given file spec, consulting the targets
354// "black list".
356 const lldb::TargetSP& target_sp,
357 const StructuredData::Dictionary &data_dict,
358 Status &error) {
359 // No options for an unconstrained search.
360 return std::make_shared<SearchFilterForUnconstrainedSearches>(target_sp);
361}
362
365 // The options dictionary is an empty dictionary:
366 auto result_sp = std::make_shared<StructuredData::Dictionary>();
367 return WrapOptionsDict(result_sp);
368}
369
371 const FileSpec &module_spec) {
372 return !m_target_sp->ModuleIsExcludedForUnconstrainedSearches(module_spec);
373}
374
376 const lldb::ModuleSP &module_sp) {
377 if (!module_sp)
378 return true;
379 else if (m_target_sp->ModuleIsExcludedForUnconstrainedSearches(module_sp))
380 return false;
381 return true;
382}
383
385 return std::make_shared<SearchFilterForUnconstrainedSearches>(*this);
386}
387
388// SearchFilterByModule:
389// Selects a shared library matching a given file spec
390
392 const FileSpec &module)
393 : SearchFilter(target_sp, FilterTy::ByModule), m_module_spec(module) {}
394
396
398 return (module_sp &&
399 FileSpec::Match(m_module_spec, module_sp->GetFileSpec()));
400}
401
403 return FileSpec::Match(m_module_spec, spec);
404}
405
407 // FIXME: Not yet implemented
408 return true;
409}
410
412 if (!m_target_sp)
413 return;
414
415 if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
416 SymbolContext empty_sc;
417 empty_sc.target_sp = m_target_sp;
418 searcher.SearchCallback(*this, empty_sc, nullptr);
419 }
420
421 // If the module file spec is a full path, then we can just find the one
422 // filespec that passes. Otherwise, we need to go through all modules and
423 // find the ones that match the file name.
424
425 const ModuleList &target_modules = m_target_sp->GetImages();
426 std::lock_guard<std::recursive_mutex> guard(target_modules.GetMutex());
427
428 for (ModuleSP module_sp : m_target_sp->GetImages().Modules()) {
429 if (FileSpec::Match(m_module_spec, module_sp->GetFileSpec())) {
430 SymbolContext matchingContext(m_target_sp, module_sp);
431 Searcher::CallbackReturn shouldContinue;
432
433 shouldContinue = DoModuleIteration(matchingContext, searcher);
434 if (shouldContinue == Searcher::eCallbackReturnStop)
435 return;
436 }
437 }
438}
439
441 s->PutCString(", module = ");
443}
444
446 return eSymbolContextModule;
447}
448
450
452 return std::make_shared<SearchFilterByModule>(*this);
453}
454
456 const lldb::TargetSP& target_sp,
457 const StructuredData::Dictionary &data_dict,
458 Status &error) {
459 StructuredData::Array *modules_array;
460 bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
461 modules_array);
462 if (!success) {
463 error.SetErrorString("SFBM::CFSD: Could not find the module list key.");
464 return nullptr;
465 }
466
467 size_t num_modules = modules_array->GetSize();
468 if (num_modules > 1) {
469 error.SetErrorString(
470 "SFBM::CFSD: Only one modules allowed for SearchFilterByModule.");
471 return nullptr;
472 }
473
474 std::optional<llvm::StringRef> maybe_module =
475 modules_array->GetItemAtIndexAsString(0);
476 if (!maybe_module) {
477 error.SetErrorString("SFBM::CFSD: filter module item not a string.");
478 return nullptr;
479 }
480 FileSpec module_spec(*maybe_module);
481
482 return std::make_shared<SearchFilterByModule>(target_sp, module_spec);
483}
484
486 auto options_dict_sp = std::make_shared<StructuredData::Dictionary>();
487 auto module_array_sp = std::make_shared<StructuredData::Array>();
488 module_array_sp->AddItem(
489 std::make_shared<StructuredData::String>(m_module_spec.GetPath()));
490 options_dict_sp->AddItem(GetKey(OptionNames::ModList), module_array_sp);
491 return WrapOptionsDict(options_dict_sp);
492}
493
494// SearchFilterByModuleList:
495// Selects a shared library matching a given file spec
496
498 const lldb::TargetSP &target_sp, const FileSpecList &module_list)
499 : SearchFilter(target_sp, FilterTy::ByModules),
500 m_module_spec_list(module_list) {}
501
503 const lldb::TargetSP &target_sp, const FileSpecList &module_list,
504 enum FilterTy filter_ty)
505 : SearchFilter(target_sp, filter_ty), m_module_spec_list(module_list) {}
506
508
510 if (m_module_spec_list.GetSize() == 0)
511 return true;
512
513 return module_sp && m_module_spec_list.FindFileIndex(
514 0, module_sp->GetFileSpec(), false) != UINT32_MAX;
515}
516
518 if (m_module_spec_list.GetSize() == 0)
519 return true;
520
521 return m_module_spec_list.FindFileIndex(0, spec, true) != UINT32_MAX;
522}
523
525 // FIXME: Not yet implemented
526 return true;
527}
528
530 if (!m_target_sp)
531 return;
532
533 if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
534 SymbolContext empty_sc;
535 empty_sc.target_sp = m_target_sp;
536 searcher.SearchCallback(*this, empty_sc, nullptr);
537 }
538
539 // If the module file spec is a full path, then we can just find the one
540 // filespec that passes. Otherwise, we need to go through all modules and
541 // find the ones that match the file name.
542 for (ModuleSP module_sp : m_target_sp->GetImages().Modules()) {
543 if (m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec(), false) ==
545 continue;
546 SymbolContext matchingContext(m_target_sp, module_sp);
547 Searcher::CallbackReturn shouldContinue;
548
549 shouldContinue = DoModuleIteration(matchingContext, searcher);
550 if (shouldContinue == Searcher::eCallbackReturnStop)
551 return;
552 }
553}
554
556 size_t num_modules = m_module_spec_list.GetSize();
557 if (num_modules == 1) {
558 s->Printf(", module = ");
559 s->PutCString(
561 "<Unknown>"));
562 return;
563 }
564
565 s->Printf(", modules(%" PRIu64 ") = ", (uint64_t)num_modules);
566 for (size_t i = 0; i < num_modules; i++) {
567 s->PutCString(
569 "<Unknown>"));
570 if (i != num_modules - 1)
571 s->PutCString(", ");
572 }
573}
574
576 return eSymbolContextModule;
577}
578
580
582 return std::make_shared<SearchFilterByModuleList>(*this);
583}
584
586 const lldb::TargetSP& target_sp,
587 const StructuredData::Dictionary &data_dict,
588 Status &error) {
589 StructuredData::Array *modules_array;
590 bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
591 modules_array);
592
593 if (!success)
594 return std::make_shared<SearchFilterByModuleList>(target_sp,
595 FileSpecList{});
596 FileSpecList modules;
597 size_t num_modules = modules_array->GetSize();
598 for (size_t i = 0; i < num_modules; i++) {
599 std::optional<llvm::StringRef> maybe_module =
600 modules_array->GetItemAtIndexAsString(i);
601 if (!maybe_module) {
602 error.SetErrorStringWithFormat(
603 "SFBM::CFSD: filter module item %zu not a string.", i);
604 return nullptr;
605 }
606 modules.EmplaceBack(*maybe_module);
607 }
608 return std::make_shared<SearchFilterByModuleList>(target_sp, modules);
609}
610
612 StructuredData::DictionarySP &options_dict_sp) {
615}
616
618 auto options_dict_sp = std::make_shared<StructuredData::Dictionary>();
619 SerializeUnwrapped(options_dict_sp);
620 return WrapOptionsDict(options_dict_sp);
621}
622
623// SearchFilterByModuleListAndCU:
624// Selects a shared library matching a given file spec
625
627 const lldb::TargetSP &target_sp, const FileSpecList &module_list,
628 const FileSpecList &cu_list)
629 : SearchFilterByModuleList(target_sp, module_list,
630 FilterTy::ByModulesAndCU),
631 m_cu_spec_list(cu_list) {}
632
634
636 const lldb::TargetSP& target_sp,
637 const StructuredData::Dictionary &data_dict,
638 Status &error) {
639 StructuredData::Array *modules_array = nullptr;
640 SearchFilterSP result_sp;
641 bool success = data_dict.GetValueForKeyAsArray(GetKey(OptionNames::ModList),
642 modules_array);
643 FileSpecList modules;
644 if (success) {
645 size_t num_modules = modules_array->GetSize();
646 for (size_t i = 0; i < num_modules; i++) {
647 std::optional<llvm::StringRef> maybe_module =
648 modules_array->GetItemAtIndexAsString(i);
649 if (!maybe_module) {
650 error.SetErrorStringWithFormat(
651 "SFBM::CFSD: filter module item %zu not a string.", i);
652 return result_sp;
653 }
654 modules.EmplaceBack(*maybe_module);
655 }
656 }
657
658 StructuredData::Array *cus_array = nullptr;
659 success =
660 data_dict.GetValueForKeyAsArray(GetKey(OptionNames::CUList), cus_array);
661 if (!success) {
662 error.SetErrorString("SFBM::CFSD: Could not find the CU list key.");
663 return result_sp;
664 }
665
666 size_t num_cus = cus_array->GetSize();
667 FileSpecList cus;
668 for (size_t i = 0; i < num_cus; i++) {
669 std::optional<llvm::StringRef> maybe_cu =
670 cus_array->GetItemAtIndexAsString(i);
671 if (!maybe_cu) {
672 error.SetErrorStringWithFormat(
673 "SFBM::CFSD: filter CU item %zu not a string.", i);
674 return nullptr;
675 }
676 cus.EmplaceBack(*maybe_cu);
677 }
678
679 return std::make_shared<SearchFilterByModuleListAndCU>(
680 target_sp, modules, cus);
681}
682
685 auto options_dict_sp = std::make_shared<StructuredData::Dictionary>();
688 return WrapOptionsDict(options_dict_sp);
689}
690
692 SymbolContext sym_ctx;
693 address.CalculateSymbolContext(&sym_ctx, eSymbolContextEverything);
694 if (!sym_ctx.comp_unit) {
695 if (m_cu_spec_list.GetSize() != 0)
696 return false; // Has no comp_unit so can't pass the file check.
697 }
698 FileSpec cu_spec;
699 if (sym_ctx.comp_unit)
700 cu_spec = sym_ctx.comp_unit->GetPrimaryFile();
701 if (m_cu_spec_list.FindFileIndex(0, cu_spec, false) == UINT32_MAX)
702 return false; // Fails the file check
704}
705
707 return m_cu_spec_list.FindFileIndex(0, fileSpec, false) != UINT32_MAX;
708}
709
711 bool in_cu_list = m_cu_spec_list.FindFileIndex(0, compUnit.GetPrimaryFile(),
712 false) != UINT32_MAX;
713 if (!in_cu_list)
714 return false;
715
716 ModuleSP module_sp(compUnit.GetModule());
717 if (!module_sp)
718 return true;
719
721}
722
724 if (!m_target_sp)
725 return;
726
727 if (searcher.GetDepth() == lldb::eSearchDepthTarget) {
728 SymbolContext empty_sc;
729 empty_sc.target_sp = m_target_sp;
730 searcher.SearchCallback(*this, empty_sc, nullptr);
731 }
732
733 // If the module file spec is a full path, then we can just find the one
734 // filespec that passes. Otherwise, we need to go through all modules and
735 // find the ones that match the file name.
736
737 ModuleList matching_modules;
738
739 bool no_modules_in_filter = m_module_spec_list.GetSize() == 0;
740 for (ModuleSP module_sp : m_target_sp->GetImages().Modules()) {
741 if (!no_modules_in_filter &&
742 m_module_spec_list.FindFileIndex(0, module_sp->GetFileSpec(), false) ==
744 continue;
745
746 SymbolContext matchingContext(m_target_sp, module_sp);
747 Searcher::CallbackReturn shouldContinue;
748
749 if (searcher.GetDepth() == lldb::eSearchDepthModule) {
750 shouldContinue = DoModuleIteration(matchingContext, searcher);
751 if (shouldContinue == Searcher::eCallbackReturnStop)
752 return;
753 continue;
754 }
755
756 const size_t num_cu = module_sp->GetNumCompileUnits();
757 for (size_t cu_idx = 0; cu_idx < num_cu; cu_idx++) {
758 CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex(cu_idx);
759 matchingContext.comp_unit = cu_sp.get();
760 if (!matchingContext.comp_unit)
761 continue;
763 0, matchingContext.comp_unit->GetPrimaryFile(), false) ==
765 continue;
766 shouldContinue = DoCUIteration(module_sp, matchingContext, searcher);
767 if (shouldContinue == Searcher::eCallbackReturnStop)
768 return;
769 }
770 }
771}
772
774 size_t num_modules = m_module_spec_list.GetSize();
775 if (num_modules == 1) {
776 s->Printf(", module = ");
777 s->PutCString(
779 "<Unknown>"));
780 } else if (num_modules > 0) {
781 s->Printf(", modules(%" PRIu64 ") = ", static_cast<uint64_t>(num_modules));
782 for (size_t i = 0; i < num_modules; i++) {
783 s->PutCString(
785 "<Unknown>"));
786 if (i != num_modules - 1)
787 s->PutCString(", ");
788 }
789 }
790}
791
793 return eSymbolContextModule | eSymbolContextCompUnit;
794}
795
797
799 return std::make_shared<SearchFilterByModuleListAndCU>(*this);
800}
static llvm::raw_ostream & error(Stream &strm)
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
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:831
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
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:188
A file collection class.
Definition: FileSpecList.h:85
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.
Definition: FileSpecList.h:146
size_t GetSize() const
Get the number of files in the file list.
size_t FindFileIndex(size_t idx, const FileSpec &file, bool full) const
Find a file index.
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
const ConstString & GetFilename() const
Filename string const get accessor.
Definition: FileSpec.h:240
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
A class that describes a function.
Definition: Function.h:399
const AddressRange & GetAddressRange()
Definition: Function.h:447
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
A collection class for Module objects.
Definition: ModuleList.h:103
std::recursive_mutex & GetMutex() const
Definition: ModuleList.h:230
ModuleIterable Modules() const
Definition: ModuleList.h:527
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
lldb::SearchFilterSP DoCreateCopy() override
bool ModulePasses(const FileSpec &module_spec) override
Call this method with a file spec to see if that spec passes the filter.
General Outline: Provides the callback and search depth for the SearchFilter search.
Definition: SearchFilter.h:83
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)
Definition: SearchFilter.h:247
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()
Definition: SearchFilter.h:213
lldb::TargetSP m_target_sp
Definition: SearchFilter.h:278
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...
const char * GetFilterName()
Definition: SearchFilter.h:236
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()
Definition: SearchFilter.h:215
Searcher::CallbackReturn DoCUIteration(const lldb::ModuleSP &module_sp, const SymbolContext &context, Searcher &searcher)
static const char * g_ty_to_name[LastKnownFilterType+2]
Definition: SearchFilter.h:227
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]
Definition: SearchFilter.h:245
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.
Definition: SearchFilter.h:42
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:44
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.
Definition: SymbolContext.h:34
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:50
virtual size_t ParseFunctions(CompileUnit &comp_unit)=0
#define UINT32_MAX
Definition: lldb-defines.h:19
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::Function > FunctionSP
Definition: lldb-forward.h:347
std::shared_ptr< lldb_private::SearchFilter > SearchFilterSP
Definition: lldb-forward.h:410
@ eSearchDepthTarget
@ eSearchDepthFunction
@ eSearchDepthModule
@ eSearchDepthCompUnit
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:436
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:365
std::shared_ptr< lldb_private::CompileUnit > CompUnitSP
Definition: lldb-forward.h:327