LLDB mainline
ProcessGDBRemote.h
Go to the documentation of this file.
1//===-- ProcessGDBRemote.h --------------------------------------*- C++ -*-===//
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
9#ifndef LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_PROCESSGDBREMOTE_H
10#define LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_PROCESSGDBREMOTE_H
11
12#include <atomic>
13#include <map>
14#include <mutex>
15#include <optional>
16#include <string>
17#include <vector>
18
25#include "lldb/Target/Process.h"
26#include "lldb/Target/Thread.h"
31#include "lldb/Utility/Status.h"
37
40
41#include "llvm/ADT/DenseMap.h"
42#include "llvm/ADT/StringMap.h"
43
44namespace lldb_private {
45namespace process_gdb_remote {
46
47class ThreadGDBRemote;
48
51public:
52 ~ProcessGDBRemote() override;
53
55 lldb::ListenerSP listener_sp,
56 const FileSpec *crash_file_path,
57 bool can_connect);
58
59 static void Initialize();
60
61 static void DebuggerInitialize(Debugger &debugger);
62
63 static void Terminate();
64
65 static llvm::StringRef GetPluginNameStatic() { return "gdb-remote"; }
66
67 static llvm::StringRef GetPluginDescriptionStatic();
68
69 static std::chrono::seconds GetPacketTimeout();
70
71 static std::chrono::milliseconds GetPacketTestDelay();
72
74
75 // Check if a given Process
76 bool CanDebug(lldb::TargetSP target_sp,
77 bool plugin_specified_by_name) override;
78
80
81 void DumpPluginHistory(Stream &s) override;
82
83 // Creating a new process, or attaching to an existing one
84 Status DoWillLaunch(Module *module) override;
85
86 Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override;
87
88 void DidLaunch() override;
89
91
92 Status DoWillAttachToProcessWithName(const char *process_name,
93 bool wait_for_launch) override;
94
95 Status DoConnectRemote(llvm::StringRef remote_url) override;
96
98
100 const ProcessAttachInfo &attach_info) override;
101
102 Status
103 DoAttachToProcessWithName(const char *process_name,
104 const ProcessAttachInfo &attach_info) override;
105
106 void DidAttach(ArchSpec &process_arch) override;
107
108 // PluginInterface protocol
109 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
110
111 // Process Control
112 Status WillResume() override;
113
114 bool SupportsReverseDirection() override;
115
116 Status DoResume(lldb::RunDirection direction) override;
117
118 Status DoHalt(bool &caused_stop) override;
119
120 Status DoDetach(bool keep_stopped) override;
121
122 bool DetachRequiresHalt() override { return true; }
123
124 Status DoSignal(int signal) override;
125
126 Status DoDestroy() override;
127
128 void RefreshStateAfterStop() override;
129
130 void SetUnixSignals(const lldb::UnixSignalsSP &signals_sp);
131
132 // Process Queries
133 bool IsAlive() override;
134
136
137 void WillPublicStop() override;
138
139 // Process Memory
140 size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size,
141 Status &error) override;
142
143 /// Override of DoReadMemoryRanges that uses MultiMemRead to perform this
144 /// operation in a single packet.
145 llvm::SmallVector<llvm::MutableArrayRef<uint8_t>>
146 DoReadMemoryRanges(llvm::ArrayRef<Range<lldb::addr_t, size_t>> ranges,
147 llvm::MutableArrayRef<uint8_t> buf) override;
148
149private:
150 llvm::Expected<StringExtractorGDBRemote>
152
153 llvm::Error ParseMultiMemReadPacket(
154 llvm::StringRef response_str, llvm::MutableArrayRef<uint8_t> buffer,
155 unsigned expected_num_ranges,
156 llvm::SmallVectorImpl<llvm::MutableArrayRef<uint8_t>> &memory_regions);
157
158public:
159 Status
160 WriteObjectFile(std::vector<ObjectFile::LoadableData> entries) override;
161
162 size_t DoWriteMemory(lldb::addr_t addr, const void *buf, size_t size,
163 Status &error) override;
164
165 lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions,
166 Status &error) override;
167
169
170 // Process STDIO
171 size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) override;
172
173 // Process Breakpoints
174 Status EnableBreakpointSite(BreakpointSite *bp_site) override;
175
176 llvm::Error UpdateBreakpointSites(
177 const BreakpointSiteToActionMap &site_to_action) override;
178
180
181 // Process Watchpoints
183 bool notify = true) override;
184
186 bool notify = true) override;
187
188 std::optional<uint32_t> GetWatchpointSlotCount() override;
189
190 llvm::Expected<TraceSupportedResponse> TraceSupported() override;
191
192 llvm::Error TraceStop(const TraceStopRequest &request) override;
193
194 llvm::Error TraceStart(const llvm::json::Value &request) override;
195
196 llvm::Expected<std::string> TraceGetState(llvm::StringRef type) override;
197
198 llvm::Expected<std::vector<uint8_t>>
199 TraceGetBinaryData(const TraceGetBinaryDataRequest &request) override;
200
201 std::optional<bool> DoGetWatchpointReportedAfter() override;
202
203 bool StartNoticingNewThreads() override;
204
205 bool StopNoticingNewThreads() override;
206
208
209 Status SendEventData(const char *data) override;
210
211 // Override DidExit so we can disconnect from the remote GDB server
212 void DidExit() override;
213
214 void SetUserSpecifiedMaxMemoryTransferSize(uint64_t user_specified_max);
215
216 bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch,
217 ModuleSpec &module_spec) override;
218
219 void PrefetchModuleSpecs(llvm::ArrayRef<FileSpec> module_file_specs,
220 const llvm::Triple &triple) override;
221
222 llvm::VersionTuple GetHostOSVersion() override;
223 llvm::VersionTuple GetHostMacCatalystVersion() override;
224
225 llvm::Error LoadModules() override;
226
227 llvm::Expected<LoadedModuleInfoList> GetLoadedModuleList() override;
228
229 Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded,
230 lldb::addr_t &load_addr) override;
231
232 void ModulesDidLoad(ModuleList &module_list) override;
233
236 lldb::addr_t image_count) override;
237
238 Status
239 ConfigureStructuredData(llvm::StringRef type_name,
240 const StructuredData::ObjectSP &config_sp) override;
241
243 lldb::BinaryInformationLevel info_level) override;
244
247 const std::vector<lldb::addr_t> &load_addresses) override;
248
251
253
255
257 StringExtractorGDBRemote &inputStringExtractor);
258
259 void DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid,
260 bool is_expression_fork = false) override;
261 void DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid,
262 bool is_expression_fork = false) override;
263 void DidVForkDone() override;
264 void DidExec() override;
265
266 llvm::Expected<bool> SaveCore(llvm::StringRef outfile) override;
267
268protected:
269 friend class ThreadGDBRemote;
272
273 ProcessGDBRemote(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp);
274
275 virtual std::shared_ptr<ThreadGDBRemote> CreateThread(lldb::tid_t tid);
276
277 bool SupportsMemoryTagging() override;
278
279 /// Broadcaster event bits definitions.
280 enum {
284 };
285
287 std::atomic<lldb::pid_t> m_debugserver_pid;
288
289 /// Registration for the packet-history diagnostics provider, if enabled.
290 std::optional<Diagnostics::ArtifactProviderID> m_diagnostics_artifact_id;
291
292 std::optional<StringExtractorGDBRemote> m_last_stop_packet;
293 std::recursive_mutex m_last_stop_packet_mutex;
294
299 std::recursive_mutex m_async_thread_state_mutex;
300 typedef std::vector<lldb::tid_t> tid_collection;
301 typedef std::vector<std::pair<lldb::tid_t, int>> tid_sig_collection;
302 typedef std::map<lldb::addr_t, lldb::addr_t> MMapMap;
303 typedef std::map<uint32_t, std::string> ExpeditedRegisterMap;
304 tid_collection m_thread_ids; // Thread IDs for all threads. This list gets
305 // updated after stopping
306 std::vector<lldb::addr_t> m_thread_pcs; // PC values for all the threads.
307 StructuredData::ObjectSP m_jstopinfo_sp; // Stop info only for any threads
308 // that have valid stop infos
309 StructuredData::ObjectSP m_jthreadsinfo_sp; // Full stop info, expedited
310 // registers and memory for all
311 // threads if "jThreadsInfo"
312 // packet is supported
316 tid_sig_collection m_continue_C_tids; // 'C' for continue with signal
318 tid_sig_collection m_continue_S_tids; // 'S' for step with signal
319 uint64_t m_max_memory_size; // The maximum number of bytes to read/write when
320 // reading and writing memory
321 uint64_t m_remote_stub_max_memory_size; // The maximum memory size the remote
322 // gdb stub can handle
328 lldb::tid_t m_initial_tid; // The initial thread ID, given by stub on attach
330 LLDB_INVALID_THREAD_ID; // Thread ID from the most recent
331 // T-packet's "thread:<tid>" key.
333
338
339 // Number of vfork() operations being handled.
341
342 // Accessors
344 return state == lldb::eStateRunning || IsStepping(state);
345 }
346
348 return state == lldb::eStateStepping;
349 }
350
351 bool CanResume(lldb::StateType state) { return state == lldb::eStateStopped; }
352
353 bool HasExited(lldb::StateType state) { return state == lldb::eStateExited; }
354
355 void Clear();
356
357 bool DoUpdateThreadList(ThreadList &old_thread_list,
358 ThreadList &new_thread_list) override;
359
361
363
365
366 void BuildDynamicRegisterInfo(bool force);
367
368 void SetLastStopPacket(const StringExtractorGDBRemote &response);
369
370 bool ParsePythonTargetDefinition(const FileSpec &target_definition_fspec);
371
372 DataExtractor GetAuxvData() override;
373
375
376 void GetMaxMemorySize();
377
379
380 size_t UpdateThreadPCsFromStopReplyThreadsValue(llvm::StringRef value);
381
382 size_t UpdateThreadIDsFromStopReplyThreadsValue(llvm::StringRef value);
383
384 bool StartAsyncThread();
385
386 void StopAsyncThread();
387
389
390 static void
391 MonitorDebugserverProcess(std::weak_ptr<ProcessGDBRemote> process_wp,
392 lldb::pid_t pid, int signo, int exit_status);
393
395
396 bool
398 const StructuredData::ObjectSP &thread_infos_sp);
399
401
404 ExpeditedRegisterMap &expedited_register_map, uint8_t signo,
405 const std::string &thread_name, const std::string &reason,
406 const std::string &description, uint32_t exc_type,
407 const std::vector<lldb::addr_t> &exc_data,
408 lldb::addr_t thread_dispatch_qaddr, bool queue_vars_valid,
409 lldb_private::LazyBool associated_with_libdispatch_queue,
410 lldb::addr_t dispatch_queue_t, std::string &queue_name,
411 lldb::QueueKind queue_kind, uint64_t queue_serial,
412 std::vector<lldb::addr_t> &added_binaries,
413 StructuredData::ObjectSP &detailed_binaries_info);
414
415 void ClearThreadIDList();
416
417 bool UpdateThreadIDList();
418
419 void DidLaunchOrAttach(ArchSpec &process_arch);
420 void LoadStubBinaries();
422
423 Status ConnectToDebugserver(llvm::StringRef host_port);
424
425 const char *GetDispatchQueueNameForThread(lldb::addr_t thread_dispatch_qaddr,
426 std::string &dispatch_queue_name);
427
429
431 ArchSpec &arch_to_use, std::string xml_filename,
432 std::vector<DynamicRegisterInfo::Register> &registers);
433
434 // Convert DynamicRegisterInfo::Registers into RegisterInfos and add
435 // to the dynamic register list.
436 void AddRemoteRegisters(std::vector<DynamicRegisterInfo::Register> &registers,
437 const ArchSpec &arch_to_use);
438 // Query remote GDBServer for register information
439 llvm::Error GetGDBServerRegisterInfo(ArchSpec &arch);
440
442 lldb::addr_t link_map,
443 lldb::addr_t base_addr,
444 bool value_is_offset);
445
447
448 Status FlashErase(lldb::addr_t addr, size_t size);
449
451
452 bool HasErased(FlashRange range);
453
454 llvm::Expected<std::vector<uint8_t>>
455 DoReadMemoryTags(lldb::addr_t addr, size_t len, int32_t type) override;
456
457 Status DoWriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type,
458 const std::vector<uint8_t> &tags) override;
459
461 MemoryRegionInfo &region_info) override;
462
463private:
464 // For ProcessGDBRemote only
466 std::map<uint64_t, uint32_t> m_thread_id_to_used_usec_map;
468
469 /// Enable a single breakpoint site by trying Z0 (software), then Z1
470 /// (hardware), then manual memory write as a last resort.
471 llvm::Error DoEnableBreakpointSite(BreakpointSite &bp_site);
472
473 /// Disable a single breakpoint site directly by sending the appropriate
474 /// z packet or restoring the original instruction.
475 llvm::Error DoDisableBreakpointSite(BreakpointSite &bp_site);
476
478 const BreakpointSiteToActionMap &site_to_action);
479
480 static bool NewThreadNotifyBreakpointHit(void *baton,
482 lldb::user_id_t break_id,
483 lldb::user_id_t break_loc_id);
484
485 /// Remove the breakpoints associated with thread creation from the Target.
487
488 /// Handle a set of actions requested by an accelerator plugin. Currently this
489 /// only sets the breakpoints requested in \a actions.
490 llvm::Error HandleAcceleratorActions(const AcceleratorActions &actions);
491
492 /// Set the breakpoints requested by an accelerator plugin as internal
493 /// breakpoints with a callback that notifies the plugin when they are hit.
494 /// Returns an error if any breakpoint could not be set; the remaining
495 /// breakpoints are still set.
496 llvm::Error HandleAcceleratorBreakpoints(const AcceleratorActions &actions);
497
498 /// Create a new target for an accelerator and connect it to the GDB server
499 /// described by the action's connection info.
500 llvm::Error HandleAcceleratorConnection(const AcceleratorActions &actions);
501
502 /// Breakpoint callback invoked when an accelerator-plugin-requested
503 /// breakpoint is hit. Resolves any requested symbol values, notifies the
504 /// plugin via the "jAcceleratorPluginBreakpointHit" packet, and handles the
505 /// response.
507 void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id,
508 lldb::user_id_t break_loc_id);
509
510 bool AcceleratorBreakpointHit(void *baton, StoppointCallbackContext *context,
511 lldb::user_id_t break_id,
512 lldb::user_id_t break_loc_id);
513
514 /// Tracks the last action identifier handled per accelerator plugin so the
515 /// same actions are not processed more than once. Accelerator actions can
516 /// arrive in a stop reply packet, and if the debugger re-requests the stop
517 /// reply with a '?' packet we can be handed the same actions again; this
518 /// guards against handling them (e.g. setting the same breakpoints) twice.
519 std::map<std::string, int64_t> m_processed_accelerator_actions;
520
521 // ContinueDelegate interface
522 void HandleAsyncStdout(llvm::StringRef out) override;
523 void HandleAsyncMisc(llvm::StringRef data) override;
524 void HandleStopReply() override;
525 void HandleAsyncStructuredDataPacket(llvm::StringRef data) override;
526
528 HandleThreadAsyncInterrupt(uint8_t signo,
529 const std::string &description) override;
530
531 void SetThreadPc(const lldb::ThreadSP &thread_sp, uint64_t index);
532 using ModuleCacheKey = std::pair<std::string, std::string>;
533 // KeyInfo for the cached module spec DenseMap.
534 // The invariant is that all real keys will have the file and architecture
535 // set.
536 // The comparison and hash functions take the file name and architecture
537 // triple into account.
539 static unsigned getHashValue(const ModuleCacheKey &key) {
540 return llvm::hash_combine(key.first, key.second);
541 }
542
543 static bool isEqual(const ModuleCacheKey &LHS, const ModuleCacheKey &RHS) {
544 return LHS == RHS;
545 }
546 };
547
548 llvm::DenseMap<ModuleCacheKey, ModuleSpec, ModuleCacheInfo>
550
553
554 // fork helpers
555 void DidForkSwitchSoftwareBreakpoints(bool enable,
556 bool is_expression_fork = false);
557 void DidForkSwitchHardwareTraps(bool enable);
558
559 void ParseExpeditedRegisters(ExpeditedRegisterMap &expedited_register_map,
560 lldb::ThreadSP thread_sp);
561
562 // Lists of register fields generated from the remote's target XML.
563 // Pointers to these RegisterFlags will be set in the register info passed
564 // back to the upper levels of lldb. Doing so is safe because this class will
565 // live at least as long as the debug session. We therefore do not store the
566 // data directly in the map because the map may reallocate it's storage as new
567 // entries are added. Which would invalidate any pointers set in the register
568 // info up to that point.
569 llvm::StringMap<std::unique_ptr<RegisterFlags>> m_registers_flags_types;
570
571 // Enum types are referenced by register fields. This does not store the data
572 // directly because the map may reallocate. Pointers to these are contained
573 // within instances of RegisterFlags.
574 llvm::StringMap<std::unique_ptr<FieldEnum>> m_registers_enum_types;
575};
576
577} // namespace process_gdb_remote
578} // namespace lldb_private
579
580#endif // LLDB_SOURCE_PLUGINS_PROCESS_GDB_REMOTE_PROCESSGDBREMOTE_H
static llvm::raw_ostream & error(Stream &strm)
An architecture specification class.
Definition ArchSpec.h:32
Class that manages the actual breakpoint that will be inserted into the running program.
Broadcaster(lldb::BroadcasterManagerSP manager_sp, std::string name)
Construct with a broadcaster with a name.
An data extractor class.
A file utility class.
Definition FileSpec.h:57
A collection class for Module objects.
Definition ModuleList.h:125
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:91
Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
Construct with a shared pointer to a target, and the Process listener.
Definition Process.cpp:453
std::map< lldb::BreakpointSiteSP, BreakpointAction, SiteIDCmp > BreakpointSiteToActionMap
Definition Process.h:2314
friend class DynamicLoader
Definition Process.h:362
friend class Debugger
Definition Process.h:361
An error handling class.
Definition Status.h:118
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
A stream class that can stream formatted output to a file.
Definition Stream.h:28
std::shared_ptr< Object > ObjectSP
Status FlashErase(lldb::addr_t addr, size_t size)
Status DisableWatchpoint(lldb::WatchpointSP wp_sp, bool notify=true) override
llvm::SmallVector< llvm::MutableArrayRef< uint8_t > > DoReadMemoryRanges(llvm::ArrayRef< Range< lldb::addr_t, size_t > > ranges, llvm::MutableArrayRef< uint8_t > buf) override
Override of DoReadMemoryRanges that uses MultiMemRead to perform this operation in a single packet.
static bool AcceleratorBreakpointHitCallback(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
Breakpoint callback invoked when an accelerator-plugin-requested breakpoint is hit.
Status DoConnectRemote(llvm::StringRef remote_url) override
Attach to a remote system via a URL.
void HandleAsyncStructuredDataPacket(llvm::StringRef data) override
Process asynchronously-received structured data.
llvm::Error DoDisableBreakpointSite(BreakpointSite &bp_site)
Disable a single breakpoint site directly by sending the appropriate z packet or restoring the origin...
Status LaunchAndConnectToDebugserver(const ProcessInfo &process_info)
virtual std::shared_ptr< ThreadGDBRemote > CreateThread(lldb::tid_t tid)
StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos(lldb::addr_t image_list_address, lldb::addr_t image_count) override
Retrieve the list of shared libraries that are loaded for this process This method is used on pre-mac...
llvm::Error HandleAcceleratorActions(const AcceleratorActions &actions)
Handle a set of actions requested by an accelerator plugin.
lldb::StateType SetThreadStopInfo(StringExtractor &stop_packet)
static void MonitorDebugserverProcess(std::weak_ptr< ProcessGDBRemote > process_wp, lldb::pid_t pid, int signo, int exit_status)
StructuredData::ObjectSP GetSharedCacheInfo() override
Status DisableBreakpointSite(BreakpointSite *bp_site) override
Status EnableWatchpoint(lldb::WatchpointSP wp_sp, bool notify=true) override
Status DoSignal(int signal) override
Sends a process a UNIX signal signal.
Status DoDeallocateMemory(lldb::addr_t ptr) override
Actually deallocate memory in the process.
bool ParsePythonTargetDefinition(const FileSpec &target_definition_fspec)
llvm::Error UpdateBreakpointSitesNotBatched(const BreakpointSiteToActionMap &site_to_action)
bool StopNoticingNewThreads() override
Call this to turn off the stop & notice new threads mode.
static bool NewThreadNotifyBreakpointHit(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
void DidFork(lldb::pid_t child_pid, lldb::tid_t child_tid, bool is_expression_fork=false) override
Called after a reported fork.
void DumpPluginHistory(Stream &s) override
The underlying plugin might store the low-level communication history for this session.
Status DoDetach(bool keep_stopped) override
Detaches from a running or stopped process.
lldb::addr_t DoAllocateMemory(size_t size, uint32_t permissions, Status &error) override
Actually allocate memory in the process.
std::optional< bool > DoGetWatchpointReportedAfter() override
Provide an override value in the subclass for lldb's CPU-based logic for whether watchpoint exception...
void DidVFork(lldb::pid_t child_pid, lldb::tid_t child_tid, bool is_expression_fork=false) override
Called after a reported vfork.
std::optional< uint32_t > GetWatchpointSlotCount() override
Get the number of watchpoints supported by this target.
llvm::Expected< std::vector< uint8_t > > DoReadMemoryTags(lldb::addr_t addr, size_t len, int32_t type) override
Does the final operation to read memory tags.
llvm::DenseMap< ModuleCacheKey, ModuleSpec, ModuleCacheInfo > m_cached_module_specs
Status DoWillAttachToProcessWithID(lldb::pid_t pid) override
Called before attaching to a process.
void DidForkSwitchSoftwareBreakpoints(bool enable, bool is_expression_fork=false)
Status DoResume(lldb::RunDirection direction) override
Resumes all of a process's threads as configured using the Thread run control functions.
const ProcessGDBRemote & operator=(const ProcessGDBRemote &)=delete
Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &region_info) override
DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has removed non address bits from loa...
size_t UpdateThreadIDsFromStopReplyThreadsValue(llvm::StringRef value)
Status GetFileLoadAddress(const FileSpec &file, bool &is_loaded, lldb::addr_t &load_addr) override
Try to find the load address of a file.
bool GetThreadStopInfoFromJSON(ThreadGDBRemote *thread, const StructuredData::ObjectSP &thread_infos_sp)
void DidLaunch() override
Called after launching a process.
void SetUserSpecifiedMaxMemoryTransferSize(uint64_t user_specified_max)
void AddRemoteRegisters(std::vector< DynamicRegisterInfo::Register > &registers, const ArchSpec &arch_to_use)
void HandleAsyncStdout(llvm::StringRef out) override
std::map< uint32_t, std::string > ExpeditedRegisterMap
llvm::Error TraceStop(const TraceStopRequest &request) override
Stop tracing a live process or its threads.
StructuredData::ObjectSP GetExtendedInfoForThread(lldb::tid_t tid)
llvm::Error DoEnableBreakpointSite(BreakpointSite &bp_site)
Enable a single breakpoint site by trying Z0 (software), then Z1 (hardware), then manual memory write...
lldb::ThreadSP HandleThreadAsyncInterrupt(uint8_t signo, const std::string &description) override
Handle thread specific async interrupt and return the original thread that requested the async interr...
llvm::Expected< LoadedModuleInfoList > GetLoadedModuleList() override
Query remote GDBServer for a detailed loaded library list.
bool AcceleratorBreakpointHit(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
llvm::Error HandleAcceleratorConnection(const AcceleratorActions &actions)
Create a new target for an accelerator and connect it to the GDB server described by the action's con...
Status DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info) override
Attach to an existing process using a process ID.
llvm::StringMap< std::unique_ptr< FieldEnum > > m_registers_enum_types
Status EstablishConnectionIfNeeded(const ProcessInfo &process_info)
llvm::Error UpdateBreakpointSites(const BreakpointSiteToActionMap &site_to_action) override
Status DoHalt(bool &caused_stop) override
Halts a running process.
llvm::Expected< TraceSupportedResponse > TraceSupported() override
Get the processor tracing type supported for this process.
std::map< std::string, int64_t > m_processed_accelerator_actions
Tracks the last action identifier handled per accelerator plugin so the same actions are not processe...
llvm::Error TraceStart(const llvm::json::Value &request) override
Start tracing a process or its threads.
void ParseExpeditedRegisters(ExpeditedRegisterMap &expedited_register_map, lldb::ThreadSP thread_sp)
lldb_private::RangeVector< lldb::addr_t, size_t > FlashRangeVector
void WillPublicStop() override
Called when the process is about to broadcast a public stop.
const char * GetDispatchQueueNameForThread(lldb::addr_t thread_dispatch_qaddr, std::string &dispatch_queue_name)
bool StartNoticingNewThreads() override
Call this to set the lldb in the mode where it breaks on new thread creations, and then auto-restarts...
DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
void RemoveNewThreadBreakpoints()
Remove the breakpoints associated with thread creation from the Target.
ArchSpec GetSystemArchitecture() override
Get the system architecture for this process.
Status ConfigureStructuredData(llvm::StringRef type_name, const StructuredData::ObjectSP &config_sp) override
Configure asynchronous structured data feature.
bool SupportsReverseDirection() override
Reports whether this process supports reverse execution.
void DidExec() override
Called after a process re-execs itself.
size_t PutSTDIN(const char *buf, size_t buf_size, Status &error) override
Puts data into this process's STDIN.
std::map< lldb::addr_t, lldb::addr_t > MMapMap
Status DoAttachToProcessWithName(const char *process_name, const ProcessAttachInfo &attach_info) override
Attach to an existing process using a partial process name.
StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos_sender(StructuredData::ObjectSP args)
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
void SetThreadPc(const lldb::ThreadSP &thread_sp, uint64_t index)
Status ConnectToDebugserver(llvm::StringRef host_port)
void SetUnixSignals(const lldb::UnixSignalsSP &signals_sp)
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, Status &error) override
Actually do the reading of memory from a process.
std::optional< StringExtractorGDBRemote > m_last_stop_packet
CommandObject * GetPluginCommandObject() override
Return a multi-word command object that can be used to expose plug-in specific commands.
size_t DoWriteMemory(lldb::addr_t addr, const void *buf, size_t size, Status &error) override
Actually do the writing of memory to a process.
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override
Launch a new process.
void DidVForkDone() override
Called after reported vfork completion.
std::string HarmonizeThreadIdsForProfileData(StringExtractorGDBRemote &inputStringExtractor)
bool GetGDBServerRegisterInfoXMLAndProcess(ArchSpec &arch_to_use, std::string xml_filename, std::vector< DynamicRegisterInfo::Register > &registers)
Status DoWillAttachToProcessWithName(const char *process_name, bool wait_for_launch) override
Called before attaching to a process.
std::pair< std::string, std::string > ModuleCacheKey
bool SupportsMemoryTagging() override
Check whether the process supports memory tagging.
std::vector< std::pair< lldb::tid_t, int > > tid_sig_collection
size_t UpdateThreadPCsFromStopReplyThreadsValue(llvm::StringRef value)
llvm::VersionTuple GetHostOSVersion() override
Sometimes the connection to a process can detect the host OS version that the process is running on.
llvm::Expected< StringExtractorGDBRemote > SendMultiMemReadPacket(llvm::ArrayRef< Range< lldb::addr_t, size_t > > ranges)
std::map< uint64_t, uint32_t > m_thread_id_to_used_usec_map
Status DoWriteMemoryTags(lldb::addr_t addr, size_t len, int32_t type, const std::vector< uint8_t > &tags) override
Does the final operation to write memory tags.
llvm::Error ParseMultiMemReadPacket(llvm::StringRef response_str, llvm::MutableArrayRef< uint8_t > buffer, unsigned expected_num_ranges, llvm::SmallVectorImpl< llvm::MutableArrayRef< uint8_t > > &memory_regions)
llvm::Expected< std::vector< uint8_t > > TraceGetBinaryData(const TraceGetBinaryDataRequest &request) override
Get binary data given a trace technology and a data identifier.
llvm::Error HandleAcceleratorBreakpoints(const AcceleratorActions &actions)
Set the breakpoints requested by an accelerator plugin as internal breakpoints with a callback that n...
Status EnableBreakpointSite(BreakpointSite *bp_site) override
void ModulesDidLoad(ModuleList &module_list) override
ProcessGDBRemote(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
Status WillResume() override
Called before resuming to a process.
lldb::ModuleSP LoadModuleAtAddress(const FileSpec &file, lldb::addr_t link_map, lldb::addr_t base_addr, bool value_is_offset)
void SetLastStopPacket(const StringExtractorGDBRemote &response)
Status WriteObjectFile(std::vector< ObjectFile::LoadableData > entries) override
static std::chrono::milliseconds GetPacketTestDelay()
llvm::Error LoadModules() override
Sometimes processes know how to retrieve and load shared libraries.
void HandleAsyncMisc(llvm::StringRef data) override
ProcessGDBRemote(const ProcessGDBRemote &)=delete
lldb::addr_t GetImageInfoAddress() override
Get the image information address for the current process.
bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
void PrefetchModuleSpecs(llvm::ArrayRef< FileSpec > module_file_specs, const llvm::Triple &triple) override
StructuredData::ObjectSP GetDynamicLoaderProcessState() override
bool GetModuleSpec(const FileSpec &module_file_spec, const ArchSpec &arch, ModuleSpec &module_spec) override
Try to fetch the module specification for a module with the given file name and architecture.
llvm::StringMap< std::unique_ptr< RegisterFlags > > m_registers_flags_types
Status DoWillLaunch(Module *module) override
Called before launching to a process.
void DidAttach(ArchSpec &process_arch) override
Called after attaching a process.
llvm::Expected< bool > SaveCore(llvm::StringRef outfile) override
Save core dump into the specified file.
std::optional< Diagnostics::ArtifactProviderID > m_diagnostics_artifact_id
Registration for the packet-history diagnostics provider, if enabled.
llvm::Expected< std::string > TraceGetState(llvm::StringRef type) override
Get the current tracing state of the process and its threads.
bool IsAlive() override
Check if a process is still alive.
#define LLDB_INVALID_THREAD_ID
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::DynamicRegisterInfo > DynamicRegisterInfoSP
RunDirection
Execution directions.
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
void * thread_result_t
Definition lldb-types.h:62
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
StateType
Process and Thread States.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateRunning
Process or thread is running and can't be examined.
@ eStateExited
Process has exited and can't be examined.
@ eStateStepping
Process or thread is in the process of stepping and can not be examined.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
std::shared_ptr< lldb_private::Process > ProcessSP
uint64_t pid_t
Definition lldb-types.h:83
QueueKind
Queue type.
std::shared_ptr< lldb_private::Watchpoint > WatchpointSP
std::shared_ptr< lldb_private::Listener > ListenerSP
uint64_t user_id_t
Definition lldb-types.h:82
uint64_t addr_t
Definition lldb-types.h:80
BinaryInformationLevel
When the Process plugin can retrieve information about all binaries loaded in the target process,...
std::shared_ptr< lldb_private::Target > TargetSP
uint64_t tid_t
Definition lldb-types.h:84
std::shared_ptr< lldb_private::Module > ModuleSP
Actions to be performed in the native process on behalf of an accelerator plugin.
jLLDBTraceGetBinaryData gdb-remote packet
jLLDBTraceStop gdb-remote packet
static bool isEqual(const ModuleCacheKey &LHS, const ModuleCacheKey &RHS)