tree: b94ba3a4d189999165a5c87f33624b1d0214a449 [search]
  1. analytics.cc
  2. analytics.h
  3. analytics_event.cc
  4. analytics_event.h
  5. analytics_event_unittest.cc
  6. analytics_reporter.cc
  7. analytics_reporter.h
  8. arch_info.cc
  9. arch_info.h
  10. async_task.cc
  11. async_task.h
  12. async_task_provider.h
  13. async_task_tree.cc
  14. async_task_tree.h
  15. breakpoint.cc
  16. breakpoint.h
  17. breakpoint_action.cc
  18. breakpoint_action.h
  19. breakpoint_impl.cc
  20. breakpoint_impl.h
  21. breakpoint_impl_unittest.cc
  22. breakpoint_location.cc
  23. breakpoint_location.h
  24. breakpoint_location_impl.cc
  25. breakpoint_location_impl.h
  26. breakpoint_observer.h
  27. breakpoint_settings.cc
  28. breakpoint_settings.h
  29. BUILD.gn
  30. call_function_thread_controller.cc
  31. call_function_thread_controller.h
  32. call_function_thread_controller_arm64.cc
  33. call_function_thread_controller_arm64.h
  34. call_function_thread_controller_x64.cc
  35. call_function_thread_controller_x64.h
  36. call_site_symbol_data_provider.cc
  37. call_site_symbol_data_provider.h
  38. call_site_symbol_data_provider_unittest.cc
  39. client_eval_context_impl.cc
  40. client_eval_context_impl.h
  41. client_eval_context_impl_unittest.cc
  42. client_object.cc
  43. client_object.h
  44. component_observer.h
  45. disassembler.cc
  46. disassembler.h
  47. disassembler_unittest.cc
  48. download_manager.cc
  49. download_manager.h
  50. download_manager_unittest.cc
  51. download_observer.h
  52. elf_memory_region.cc
  53. elf_memory_region.h
  54. elf_memory_region_unittest.cc
  55. exception_settings.cc
  56. exception_settings.h
  57. execution_scope.cc
  58. execution_scope.h
  59. file_memory_region.cc
  60. file_memory_region.h
  61. filter.cc
  62. filter.h
  63. filter_unittest.cc
  64. finish_physical_frame_thread_controller.cc
  65. finish_physical_frame_thread_controller.h
  66. finish_physical_frame_thread_controller_unittest.cc
  67. finish_thread_controller.cc
  68. finish_thread_controller.h
  69. finish_thread_controller_unittest.cc
  70. frame.cc
  71. frame.h
  72. frame_fingerprint.cc
  73. frame_fingerprint.h
  74. frame_fingerprint_unittest.cc
  75. frame_impl.cc
  76. frame_impl.h
  77. frame_impl_unittest.cc
  78. frame_symbol_data_provider.cc
  79. frame_symbol_data_provider.h
  80. fuchsia_async_rust_task_provider.cc
  81. fuchsia_async_rust_task_provider.h
  82. fuchsia_async_rust_task_provider_unittest.cc
  83. function_return_info.cc
  84. function_return_info.h
  85. function_step.cc
  86. function_step.h
  87. function_thread_controller.cc
  88. function_thread_controller.h
  89. function_thread_controller_unittest.cc
  90. inline_thread_controller_test.cc
  91. inline_thread_controller_test.h
  92. map_setting_store.cc
  93. map_setting_store.h
  94. map_setting_store_unittest.cc
  95. memory_dump.cc
  96. memory_dump.h
  97. memory_dump_unittest.cc
  98. minidump_memory.cc
  99. minidump_memory.h
  100. minidump_memory_unittest.cc
  101. minidump_remote_api.cc
  102. minidump_remote_api.h
  103. minidump_unittest.cc
  104. mock_async_task.h
  105. mock_breakpoint.cc
  106. mock_breakpoint.h
  107. mock_breakpoint_location.h
  108. mock_frame.cc
  109. mock_frame.h
  110. mock_process.cc
  111. mock_process.h
  112. mock_remote_api.cc
  113. mock_remote_api.h
  114. mock_stack_delegate.h
  115. mock_symbol_server.h
  116. mock_target.cc
  117. mock_target.h
  118. mock_thread.h
  119. pretty_frame_glob.cc
  120. pretty_frame_glob.h
  121. pretty_frame_glob_unittest.cc
  122. pretty_stack_manager.cc
  123. pretty_stack_manager.h
  124. pretty_stack_manager_unittest.cc
  125. process.cc
  126. process.h
  127. process_impl.cc
  128. process_impl.h
  129. process_impl_unittest.cc
  130. process_observer.cc
  131. process_observer.h
  132. process_symbol_data_provider.cc
  133. process_symbol_data_provider.h
  134. process_symbol_data_provider_unittest.cc
  135. README.md
  136. remote_api.h
  137. remote_api_impl.cc
  138. remote_api_impl.h
  139. remote_api_test.cc
  140. remote_api_test.h
  141. session.cc
  142. session.h
  143. session_observer.cc
  144. session_observer.h
  145. session_unittest.cc
  146. setting_schema.cc
  147. setting_schema.h
  148. setting_schema_definition.cc
  149. setting_schema_definition.h
  150. setting_schema_unittest.cc
  151. setting_store.cc
  152. setting_store.h
  153. setting_store_observer.h
  154. setting_value.cc
  155. setting_value.h
  156. setting_value_unittest.cc
  157. socket_connect.cc
  158. socket_connect.h
  159. source_file_provider_impl.cc
  160. source_file_provider_impl.h
  161. source_file_provider_impl_unittest.cc
  162. stack.cc
  163. stack.h
  164. stack_unittest.cc
  165. step_into_specific_thread_controller.cc
  166. step_into_specific_thread_controller.h
  167. step_into_specific_thread_controller_unittest.cc
  168. step_into_thread_controller.cc
  169. step_into_thread_controller.h
  170. step_into_thread_controller_unittest.cc
  171. step_mode.h
  172. step_over_thread_controller.cc
  173. step_over_thread_controller.h
  174. step_over_thread_controller_unittest.cc
  175. step_thread_controller.cc
  176. step_thread_controller.h
  177. step_thread_controller_unittest.cc
  178. step_through_plt_thread_controller.cc
  179. step_through_plt_thread_controller.h
  180. step_through_plt_thread_controller_unittest.cc
  181. stop_info.h
  182. substatement.cc
  183. substatement.h
  184. substatement_unittest.cc
  185. symbol_server.cc
  186. symbol_server.h
  187. symbol_server_impl.cc
  188. symbol_server_impl.h
  189. symbol_server_unittest.cc
  190. system.cc
  191. system.h
  192. system_observer.h
  193. system_unittest.cc
  194. target.cc
  195. target.h
  196. target_impl.cc
  197. target_impl.h
  198. target_impl_unittest.cc
  199. target_observer.h
  200. test_dummy_file
  201. test_example_minidump.dmp
  202. test_example_minidump_new_cvrecord.dmp
  203. test_example_minidump_with_aspace.dmp
  204. test_thread_observer.cc
  205. test_thread_observer.h
  206. thread.cc
  207. thread.h
  208. thread_controller.cc
  209. thread_controller.h
  210. thread_controller_test.cc
  211. thread_controller_test.h
  212. thread_controller_unittest.cc
  213. thread_impl.cc
  214. thread_impl.h
  215. thread_impl_unittest.cc
  216. thread_observer.h
  217. until_process_controller.cc
  218. until_process_controller.h
  219. until_thread_controller.cc
  220. until_thread_controller.h
  221. until_thread_controller_unittest.cc
src/developer/debug/zxdb/client/README.md

Zxdb Client Library (zxdb/client)

zxdb/client is the UI-independent library for building debugger frontends. It connects to a target debug_agent, models running processes, threads, and stack frames, and exposes APIs to inspect and control target execution.

Main Objects

The client object model orders classes from largest to smallest scope.

Session

Session is the top-level connection object. It manages the connection to the remote system (Connect, Disconnect, OpenMinidump) and dispatches incoming debug_ipc notifications.

To initialize the debugger client, create a Session on a thread with an active debug::MessageLoop (//src/developer/debug/shared). Session owns the RemoteAPI instance, which unit tests often mock via MockRemoteAPI.

System

System represents global target OS state on the client. It owns the list of Target, Breakpoint, Filter, and SymbolServer objects. Session and System have a 1:1 relationship (Session owns connection state, while System owns target OS state).

Target

Target is a container for a debuggable process and its configuration (such as command-line arguments) across process runs. A Target may or may not have a running process at any moment, and System always keeps at least one Target. When the process runs, Target::GetProcess() returns its active Process object.

Process

Process represents a live attached or running process on the target. It owns the running Thread objects and exposes APIs to read and write memory or pause and continue all threads.

In the console UI, the process noun refers to a Target (which can be idle or running), whereas client::Process always represents a live process.

Thread

Thread represents a live thread inside a Process. It owns a Stack and drives thread stepping through ThreadController instances. Thread populates its Stack when it stops on an exception, though initial process or thread start exceptions may have an empty stack.

Stack

Stack manages the backtrace of a stopped Thread, including physical stack frames and synthetic inline function frames.

When a thread stops on an exception, debug_agent sends only the top 1 to 2 stack frames so internal stepping controllers avoid full stack unwinds. Callers that need the full backtrace must call Stack::SyncFrames asynchronously.

Frame

Frame represents a single stack frame (either a physical frame or an inline function call). Callers evaluate expressions and inspect local variables in the context of a frame through Frame::GetEvalContext().

Other Objects

Breakpoint

System owns all Breakpoint objects globally. A breakpoint can scope itself to a specific Target or Thread, but the Breakpoint instance itself remains owned by System.

Filter

Filter watches for matching process names, job KOIDs, or component monikers/URLs and attaches automatically when a match starts.

Thread Control

ThreadController subclasses implement thread stepping policies. To step a thread, construct the desired ThreadController subclass and pass it to Thread::ContinueWith. The controller inspects stop exceptions and continues or stops the thread:

  • FinishThreadController: Runs until the current stack frame returns.
  • StepOverThreadController: Steps over function calls on the current line.
  • StepThreadController: Steps into source lines or machine instructions.
  • UntilThreadController: Runs until execution reaches a target address.

Thread nests controllers on a stack so a thread can handle nested steps and still stop when the outer step-over finishes.

Expressions

zxdb/expr evaluates expressions and variables using an EvalContext. Callers normally get this EvalContext from Frame::GetEvalContext(), which provides access to local variables, registers, and process memory.

Interface

Public headers expose these client classes and observers:

  • zxdb::ClientObject: Base class for all client objects holding a pointer to the owning Session (client_object.h).
  • zxdb::Session, zxdb::SessionConnectionInfo, zxdb::SessionConnectionType: Top-level connection manager (Connect, Disconnect, OpenMinidump, OnStreamReadable) owning System, ArchInfo, and RemoteAPI (session.h).
  • zxdb::RemoteAPI, zxdb::MinidumpRemoteAPI: Asynchronous debug_ipc request/reply interface and its Crashpad minidump implementation (remote_api.h, minidump_remote_api.h).
  • zxdb::System, zxdb::SystemObserver: Global system state manager for Target, Breakpoint, Filter, SymbolServer, SystemSymbols, and DownloadManager (Pause, Continue, CancelAllThreadControllers) (system.h, system_observer.h).
  • zxdb::Target, zxdb::TargetObserver: Holder for a debuggable process and its configuration (State::kNone, kStarting, kAttaching, kRunning, Launch, Kill, Attach, Detach, GetProcess, GetSymbols) (target.h, target_observer.h).
  • zxdb::Process, zxdb::ProcessObserver: Live process model (GetTarget, GetKoid, GetName, GetComponentInfo, GetSymbols, GetModules, GetAspace, GetThreads, SyncThreads, Pause, Continue, ContinueUntil, ReadMemory, WriteMemory, LoadInfoHandleTable, GetAsyncTaskProvidersForLanguage) (process.h).
  • zxdb::Thread, zxdb::ThreadObserver: Live thread model (GetProcess, GetKoid, GetState, GetBlockedReason, CurrentStopInfo, Pause, Continue, ContinueWith, AddController, AddPostStopTask, CancelAllThreadControllers, ResumeFromAsyncThreadController, JumpTo, StepInstructions, GetStack, GetAsyncTaskTree) (thread.h).
  • zxdb::Stack, zxdb::Stack::Delegate: Stopped thread backtrace manager for frame synchronization (SyncFrames), inline frame expansion, and FrameFingerprint computation (stack.h).
  • zxdb::Frame: Physical or inline stack frame interface (GetThread, IsInline, GetPhysicalFrame, GetLocation, GetAddress, GetTrust, GetRegisterCategorySync, GetRegisterCategoryAsync, WriteRegister, GetSymbolDataProvider, GetEvalContext, GetSourceFileProvider) (frame.h).
  • zxdb::AsyncTask, zxdb::AsyncTaskProvider, zxdb::AsyncTaskTree, zxdb::FuchsiaAsyncRustTaskProvider: Interfaces and tree container for inspecting async tasks (such as Rust futures) on a Thread (async_task.h, async_task_tree.h).
  • zxdb::Breakpoint, zxdb::BreakpointSettings, zxdb::BreakpointLocation, zxdb::BreakpointObserver, zxdb::ExecutionScope: Global and scoped breakpoints with per-process BreakpointLocation controls (breakpoint.h, breakpoint_settings.h, breakpoint_location.h).
  • zxdb::Filter: Process, component, and job attach filter synchronized with debug_agent (filter.h).
  • zxdb::ThreadController, zxdb::StepThreadController, zxdb::StepIntoThreadController, zxdb::StepOverThreadController, zxdb::FinishThreadController, zxdb::FinishPhysicalFrameThreadController, zxdb::UntilThreadController, zxdb::UntilProcessController, zxdb::CallFunctionThreadController: Composable controllers for thread stepping, finishing, running until addresses, and calling target functions (thread_controller.h).
  • zxdb::SettingStore, zxdb::MapSettingStore, zxdb::SettingSchema, zxdb::SettingValue, zxdb::SettingStoreObserver: Schema-validated hierarchical configuration store for System, Target, Thread, Breakpoint, and Filter (setting_store.h).
  • zxdb::MemoryDump, zxdb::Disassembler, zxdb::SymbolServer, zxdb::ArchInfo, zxdb::PrettyStackManager: Memory dump container, LLVM instruction disassembler, symbol server client, architecture descriptor, and frame globbing manager.

Invariants

Callers and implementations must preserve these invariants:

  • Session and System maintain a 1:1 lifecycle correspondence, and Session owns the System instance.
  • System always contains at least one Target. System::DeleteTarget fails if the target is running or is the only remaining Target in System.
  • A Target persists across process runs (State::kNone, kStarting, kAttaching, kRunning). A Process object exists only while a process is active, and Process::GetTarget() is never null.
  • Containers own the raw pointers returned by System::GetTargets, System::GetBreakpoints, System::GetFilters, System::GetSymbolServers, Process::GetThreads, and Breakpoint::GetLocations. Never cache those raw pointers across message loop turns. Use fxl::WeakPtr instead.
  • On thread exception stops, debug_agent sends only the top 1 to 2 stack frames. Call Stack::SyncFrames asynchronously for full backtraces, and never assume Stack is non-empty on an exception stop.
  • Frame::GetRegisterCategorySync guarantees synchronous availability only for general registers. Call Frame::GetRegisterCategoryAsync on the top frame for other register categories, and call Frame::WriteRegister only on the top physical frame.
  • Active ThreadController instances evaluate thread stops via OnThreadStop returning StopOp. kFuture takes highest precedence (waiting for Thread::ResumeFromAsyncThreadController), kStopDone beats kContinue, and the thread stops if all controllers return kUnexpected.
  • Process bounds stdout_ and stderr_ capture buffers to Process::kMaxIOBufferSize (1 MiB) using circular deques.

Side Effects

zxdb/client produces these IPC, file I/O, and target side effects:

  • Serializes debug_ipc messages over debug::StreamBuffer and debug::BufferedFD to talk to the remote debug_agent.
  • Mutates remote target state over IPC by starting, attaching, detaching, and killing processes, and by suspending or resuming threads. Also writes memory (Process::WriteMemory), writes CPU registers (Frame::WriteRegister, Thread::JumpTo), sets breakpoints, and calls target functions (CallFunctionThreadController).
  • Reads local Crashpad minidumps (MinidumpRemoteAPI), reads local symbols and source files (SourceFileProviderImpl), and downloads debug symbols (DownloadManager, SymbolServer).
  • Posts asynchronous tasks to debug::MessageLoop and notifies Session, System, Target, Process, Thread, Breakpoint, Download, Component, and SettingStore observers.
  • Emits debugger usage telemetry events through AnalyticsReporter.

Verification

Run these commands to build and test zxdb/client:

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