tree: 0235253c3c59e5458a05f7c0c5e4bfa777467f15 [search]
  1. test_data/
  2. address_range_map.h
  3. address_range_map_builder.cc
  4. address_range_map_builder.h
  5. address_range_map_builder_unittest.cc
  6. address_range_map_unittest.cc
  7. arch.cc
  8. arch.h
  9. array_type.cc
  10. array_type.h
  11. base_type.cc
  12. base_type.h
  13. BUILD.gn
  14. build_id_index.cc
  15. build_id_index.h
  16. build_id_index_unittest.cc
  17. call_site.h
  18. call_site_parameter.h
  19. code_block.cc
  20. code_block.h
  21. code_block_unittest.cc
  22. collection.cc
  23. collection.h
  24. collection_unittest.cc
  25. compile_unit.cc
  26. compile_unit.h
  27. const_value.cc
  28. const_value.h
  29. const_value_unittest.cc
  30. data_member.cc
  31. data_member.h
  32. debug_symbol_file_type.h
  33. dwarf_abstract_child_iterator.h
  34. dwarf_abstract_child_iterator_unittest.cc
  35. dwarf_binary.h
  36. dwarf_binary_impl.cc
  37. dwarf_binary_impl.h
  38. dwarf_die_decoder.cc
  39. dwarf_die_decoder.h
  40. dwarf_die_ref.h
  41. dwarf_die_ref_unittest.cc
  42. dwarf_die_scanner.cc
  43. dwarf_die_scanner.h
  44. dwarf_expr.cc
  45. dwarf_expr.h
  46. dwarf_expr_eval.cc
  47. dwarf_expr_eval.h
  48. dwarf_expr_eval_unittest.cc
  49. dwarf_lang.cc
  50. dwarf_lang.h
  51. dwarf_location.cc
  52. dwarf_location.h
  53. dwarf_location_unittest.cc
  54. dwarf_stack_entry.cc
  55. dwarf_stack_entry.h
  56. dwarf_symbol_factory.cc
  57. dwarf_symbol_factory.h
  58. dwarf_symbol_factory_unittest.cc
  59. dwarf_tag.cc
  60. dwarf_tag.h
  61. dwarf_tag_unittest.cc
  62. dwarf_test_util.cc
  63. dwarf_test_util.h
  64. dwarf_unit.h
  65. dwarf_unit_impl.cc
  66. dwarf_unit_impl.h
  67. dwo_info.cc
  68. dwo_info.h
  69. elf_symbol.cc
  70. elf_symbol.h
  71. elf_symbol_record.cc
  72. elf_symbol_record.h
  73. elf_symbol_record_unittest.cc
  74. elf_symbol_unittest.cc
  75. enumeration.cc
  76. enumeration.h
  77. file_line.cc
  78. file_line.h
  79. find_line.cc
  80. find_line.h
  81. find_line_unittest.cc
  82. function.cc
  83. function.h
  84. function_call_info.h
  85. function_type.cc
  86. function_type.h
  87. function_type_unittest.cc
  88. identifier.cc
  89. identifier.h
  90. identifier_base.cc
  91. identifier_base.h
  92. identifier_unittest.cc
  93. index.cc
  94. index.h
  95. index_largetest.cc
  96. index_node.cc
  97. index_node.h
  98. index_node_unittest.cc
  99. index_perftest.cc
  100. index_test_support.cc
  101. index_test_support.h
  102. index_unittest.cc
  103. inheritance_path.cc
  104. inheritance_path.h
  105. inherited_from.cc
  106. inherited_from.h
  107. input_location.cc
  108. input_location.h
  109. lazy_symbol.cc
  110. lazy_symbol.h
  111. line_details.cc
  112. line_details.h
  113. line_table.cc
  114. line_table.h
  115. line_table_impl.cc
  116. line_table_impl.h
  117. line_table_unittest.cc
  118. loaded_module_symbols.cc
  119. loaded_module_symbols.h
  120. loaded_module_symbols_unittest.cc
  121. location.cc
  122. location.h
  123. member_ptr.cc
  124. member_ptr.h
  125. member_ptr_unittest.cc
  126. mock_line_table.cc
  127. mock_line_table.h
  128. mock_module_symbols.cc
  129. mock_module_symbols.h
  130. mock_source_file_provider.cc
  131. mock_source_file_provider.h
  132. mock_symbol_data_provider.cc
  133. mock_symbol_data_provider.h
  134. mock_symbol_data_provider_unittest.cc
  135. mock_symbol_factory.h
  136. modified_type.cc
  137. modified_type.h
  138. modified_type_unittest.cc
  139. module_indexer.cc
  140. module_indexer.h
  141. module_symbol_status.h
  142. module_symbols.cc
  143. module_symbols.h
  144. module_symbols_impl.cc
  145. module_symbols_impl.h
  146. module_symbols_impl_largetest.cc
  147. module_symbols_impl_unittest.cc
  148. namespace.cc
  149. namespace.h
  150. process_symbols.cc
  151. process_symbols.h
  152. process_symbols_test_setup.cc
  153. process_symbols_test_setup.h
  154. process_symbols_unittest.cc
  155. README.md
  156. resolve_options.h
  157. skeleton_unit.h
  158. source_file_provider.h
  159. source_util.cc
  160. source_util.h
  161. source_util_unittest.cc
  162. symbol.cc
  163. symbol.h
  164. symbol_context.cc
  165. symbol_context.h
  166. symbol_data_provider.cc
  167. symbol_data_provider.h
  168. symbol_data_provider_unittest.cc
  169. symbol_factory.cc
  170. symbol_factory.h
  171. symbol_test_parent_setter.h
  172. symbol_unittest.cc
  173. symbol_utils.cc
  174. symbol_utils.h
  175. symbol_utils_unittest.cc
  176. system_symbols.cc
  177. system_symbols.h
  178. target_symbols.cc
  179. target_symbols.h
  180. target_symbols_unittest.cc
  181. template_parameter.cc
  182. template_parameter.h
  183. test_symbol_module.cc
  184. test_symbol_module.h
  185. type.cc
  186. type.h
  187. type_test_support.cc
  188. type_test_support.h
  189. unit_index.h
  190. unit_symbol_factory.h
  191. value.cc
  192. value.h
  193. variable.cc
  194. variable.h
  195. variable_location.cc
  196. variable_location.h
  197. variable_location_unittest.cc
  198. variable_test_support.cc
  199. variable_test_support.h
  200. variant.cc
  201. variant.h
  202. variant_part.cc
  203. variant_part.h
  204. visit_scopes.cc
  205. visit_scopes.h
  206. visit_scopes_unittest.cc
src/developer/debug/zxdb/symbols/README.md

Symbol Library (zxdb/symbols)

Overview

//src/developer/debug/zxdb/symbols is the DWARF and ELF symbol indexing and lookup subsystem (Layer 2) for zxdb. It decodes DWARF Debug Information Entries (DIEs), line tables, and ELF symbols into a reference-counted object graph, and evaluates DWARF location expressions (DwarfExprEval).

Interface

Public headers expose these symbol classes, factories, and evaluators:

  • zxdb::Symbol (symbol.h): Reference-counted base class (fxl::RefCountedThreadSafe<Symbol>) for DWARF DIE symbols with manual RTTI (As<T>()). Exposes GetLazySymbol, GetDieRef, parent, GetAssignedName, GetFullName, GetIdentifier, GetCompileUnit, GetDwarfUnit, GetModuleSymbols, GetSymbolContext, and GetLanguage.
  • zxdb::Type (type.h, collection.h): Base type symbol (StripCV, StripCVT, is_declaration, byte_size). Subclasses include BaseType, ModifiedType, Collection (struct, class, union, and Rust enum or tuple), ArrayType, FunctionType, Enumeration, MemberPtr, VariantPart, and Variant.
  • zxdb::Value, zxdb::Variable, zxdb::DataMember: Named data symbols with type, is_external, artificial, const_value, and VariableLocation metadata (value.h, variable.h, data_member.h).
  • zxdb::CodeBlock, zxdb::Function, zxdb::CompileUnit: Lexical scopes, functions, inlined routines, and compilation units (code_block.h, function.h, compile_unit.h). Exposes address range queries (code_ranges, GetAbsoluteCodeRanges, ContainsAddress) and scope traversal (GetMostSpecificChild, GetContainingFunction, GetInlineChain, GetAmbiguousInlineChain).
  • zxdb::LazySymbolBase, zxdb::LazySymbol, zxdb::UncachedLazySymbol, zxdb::SymbolFactory, zxdb::DwarfSymbolFactory: Lazy DIE reference wrappers and factories that decode DwarfDieRef entries into Symbol objects on demand (lazy_symbol.h, symbol_factory.h, dwarf_symbol_factory.h).
  • zxdb::SystemSymbols, zxdb::TargetSymbols, zxdb::ProcessSymbols, zxdb::ModuleSymbols, zxdb::ModuleSymbolsImpl, zxdb::LoadedModuleSymbols: Symbol containers from global BuildIDIndex caches down to loaded modules with SymbolContext address translation (system_symbols.h, target_symbols.h, process_symbols.h, module_symbols.h, loaded_module_symbols.h).
  • zxdb::DwarfExpr, zxdb::DwarfExprEval, zxdb::SymbolDataProvider: Asynchronous stack-based DWARF expression evaluator and target memory/register provider interface (dwarf_expr.h, dwarf_expr_eval.h, symbol_data_provider.h).
  • Binary readers, symbol indices, line tables, and scope visitors: zxdb::DwarfBinary, zxdb::DwarfUnit, zxdb::DwarfDieDecoder, zxdb::DwarfDieScanner, zxdb::ElfSymbol, zxdb::Index, and zxdb::IndexNode. Also exposes zxdb::Identifier, zxdb::Location, zxdb::InputLocation, zxdb::LineTable, zxdb::LineDetails, zxdb::VariableLocation, and zxdb::VisitScopes.

Invariants

Callers and implementations must preserve these invariants:

  • Symbol objects use fxl::RefCountedThreadSafe<Symbol> and do not globally cache or deduplicate instances by DIE offset. Never compare Symbol* pointers to test semantic symbol equality.
  • Downward edges in the symbol graph (parent to child) must use cached LazySymbol instances. Upward edges (such as Symbol::parent() and Function::containing_block()) must use UncachedLazySymbol to prevent reference-counting cycles and memory leaks.
  • SymbolFactory::CreateSymbol(), LazySymbol::Get(), and UncachedLazySymbol::Get() never return nullptr. On failure or unloaded modules, they return an empty Symbol with DwarfTag::kNone.
  • Symbol, CodeBlock, and ModuleSymbols store module-relative addresses. Pass a SymbolContext bound to a loaded module's base address to convert to or from absolute process addresses.
  • TargetSymbols::ResolveInputLocation rejects address-based locations (InputLocation::Type::kAddress) because address resolution requires a running process via ProcessSymbols.
  • Use Symbol::As<Derived>() instead of C++ dynamic_cast because the build disables compiler RTTI.
  • DWARF unit offsets and type signatures of 0 are valid DWARF values (DwarfDieRef, UnitSymbolFactory, DwarfSymbolFactory). Never use 0 as an invalid sentinel. Use std::optional<uint64_t> and guard accessors with DCHECK(is_valid()).
  • DwarfSymbolFactory handles DwarfTag::kTypeUnit alongside DwarfTag::kCompileUnit so child DIEs can reach llvm::DWARFUnit via CompileUnit. DwarfBinaryImpl queries both normal compilation units (getNormalUnitsVector()) and split-DWARF DWO units (getDWOUnitsVector()).
  • When resolving a DWARF type signature whose target DwarfDieRef is invalid (!sig_ref.is_valid()), return an empty fxl::RefPtr<Symbol>() instead of crashing with FX_CHECK.

Side Effects

Using zxdb/symbols produces these disk, cache, and IPC side effects:

  • Calling Get() on a LazySymbol or UncachedLazySymbol decodes DWARF DIE records from the binary or .dwo file via SymbolFactory and caches LazySymbol::symbol_.
  • Calling Symbol::GetFullName(), Symbol::GetIdentifier(), or Collection::GetSpecialType() lazily computes and caches the formatted name, Identifier, or SpecialType on the Symbol.
  • SystemSymbols::GetModule() loads ELF and DWARF files from disk via BuildIDIndex and builds the symbol Index, or calls RequestDownloadFunction when local symbols are missing.
  • ProcessSymbols::SetModules() and RetryLoadBuildID() load and unload module symbols, update TargetSymbols, and invoke ProcessSymbols::Notifications callbacks.
  • DwarfExprEval::Eval() and SymbolDataProvider methods issue asynchronous register and memory reads and writes against the target process.

Verification

Run these commands to build and test zxdb/symbols:

  • Build: fx build //src/developer/debug/zxdb/symbols
  • Test: fx test zxdb_tests