LLDB mainline
ScriptedProcess.cpp
Go to the documentation of this file.
1//===-- ScriptedProcess.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
9#include "ScriptedProcess.h"
10
11#include "lldb/Core/Debugger.h"
12#include "lldb/Core/Module.h"
14
22#include "lldb/Target/Queue.h"
27#include "lldb/Utility/State.h"
28
30
31#include "llvm/Support/Error.h"
32
33#include <string>
34
35using namespace lldb;
36using namespace lldb_private;
37
39
41 return "Scripted Process plug-in.";
42}
43
47
49 llvm::ArrayRef<lldb::ScriptLanguage> supported_languages =
50 llvm::ArrayRef(g_supported_script_languages);
51
52 return llvm::is_contained(supported_languages, language);
53}
54
56 lldb::ListenerSP listener_sp,
57 const FileSpec *file,
58 bool can_connect) {
59 if (!target_sp ||
60 !IsScriptLanguageSupported(target_sp->GetDebugger().GetScriptLanguage()))
61 return nullptr;
62
63 ScriptedMetadata scripted_metadata(target_sp->GetProcessLaunchInfo());
64
65 if (!scripted_metadata)
66 return nullptr;
67
69 auto process_sp = std::shared_ptr<ScriptedProcess>(
70 new ScriptedProcess(target_sp, listener_sp, scripted_metadata, error));
71
72 if (error.Fail() || !process_sp || !process_sp->m_interface_up) {
73 // CreateInstance returns nullptr on failure with no Status output
74 // parameter, so we must report the error via the diagnostic system for
75 // users to see it.
76 if (error.Fail()) {
78 llvm::formatv("failed to create ScriptedProcess: {0}",
79 error.AsCString())
80 .str(),
81 target_sp->GetDebugger().GetID());
82 }
83 LLDB_LOGF(GetLog(LLDBLog::Process), "%s", error.AsCString());
84 return nullptr;
85 }
86
87 return process_sp;
88}
89
91 bool plugin_specified_by_name) {
92 return true;
93}
94
96 lldb::ListenerSP listener_sp,
97 const ScriptedMetadata &scripted_metadata,
99 : Process(target_sp, listener_sp), m_scripted_metadata(scripted_metadata) {
100
101 if (!target_sp) {
103 "ScriptedProcess::%s () - ERROR: %s", __FUNCTION__, "Invalid target");
104 return;
105 }
106
107 ScriptInterpreter *interpreter =
108 target_sp->GetDebugger().GetScriptInterpreter();
109
110 if (!interpreter) {
112 "ScriptedProcess::%s () - ERROR: %s", __FUNCTION__,
113 "Debugger has no Script Interpreter");
114 return;
115 }
116
117 // Create process instance interface
119 if (!m_interface_up) {
121 "ScriptedProcess::%s () - ERROR: %s", __FUNCTION__,
122 "Script interpreter couldn't create Scripted Process Interface");
123 return;
124 }
125
126 ExecutionContext exe_ctx(target_sp, /*get_process=*/false);
127
128 // Create process script object
129 auto obj_or_err =
131
132 if (!obj_or_err) {
133 std::string error_msg = llvm::toString(obj_or_err.takeError());
135 "failed to create script object: {0}", error_msg);
136 return;
137 }
138
139 StructuredData::GenericSP object_sp = *obj_or_err;
140
141 if (!object_sp || !object_sp->IsValid()) {
143 "ScriptedProcess::%s () - ERROR: %s", __FUNCTION__,
144 "Failed to create valid script object");
145 return;
146 }
147}
148
150 Clear();
151 // If the interface is not valid, we can't call Finalize(). When that happens
152 // it means that the Scripted Process instanciation failed and the
153 // CreateProcess function returns a nullptr, so no one besides this class
154 // should have access to that bogus process object.
155 if (!m_interface_up)
156 return;
157 // We need to call finalize on the process before destroying ourselves to
158 // make sure all of the broadcaster cleanup goes as planned. If we destruct
159 // this class, then Process::~Process() might have problems trying to fully
160 // destroy the broadcaster.
161 Finalize(true /* destructing */);
162}
163
168
172
175
176 Status error = DoLaunch(nullptr, launch_info);
177 // Process::LoadCore() doesn't go through DidLaunch().
178 if (error.Success())
180 return error;
181}
182
184 ProcessLaunchInfo &launch_info) {
185 LLDB_LOGF(GetLog(LLDBLog::Process), "ScriptedProcess::%s launching process", __FUNCTION__);
186
187 /* MARK: This doesn't reflect how lldb actually launches a process.
188 In reality, it attaches to debugserver, then resume the process.
189 That's not true in all cases. If debugserver is remote, lldb
190 asks debugserver to launch the process for it. */
193 return error;
194}
195
197
200
201 // The addressable bits are optional: without them, the process keeps the
202 // masks it inherits from the target.
205 if (!metadata_sp ||
206 !metadata_sp->GetValueForKeyAsDictionary("addressable_bits", bits))
207 return;
208
209 uint64_t lowmem_bits = 0;
210 uint64_t highmem_bits = 0;
211 bits->GetValueForKeyAsInteger("lowmem", lowmem_bits);
212 if (!bits->GetValueForKeyAsInteger("highmem", highmem_bits))
213 highmem_bits = lowmem_bits;
214
215 AddressableBits addressable_bits;
216 addressable_bits.SetAddressableBits(lowmem_bits, highmem_bits);
217 SetAddressableBitMasks(addressable_bits);
218}
219
221 // Update the PID again, in case the user provided a placeholder pid at launch
223}
224
226 LLDB_LOGF(GetLog(LLDBLog::Process), "ScriptedProcess::%s resuming process", __FUNCTION__);
227
228 if (direction == RunDirection::eRunForward)
229 return GetInterface().Resume();
230 // FIXME: Pipe reverse continue through Scripted Processes
232 "{0} does not support reverse execution of processes", GetPluginName());
233}
234
236 Status error = GetInterface().Attach(attach_info);
237 if (error.Fail()) {
239 "failed to attach to scripted process: {0}", error.AsCString());
240 return error;
241 }
244 // NOTE: We need to set the PID before finishing to attach otherwise we will
245 // hit an assert when calling the attach completion handler.
247
248 return {};
249}
250
251Status
253 const ProcessAttachInfo &attach_info) {
254 return DoAttach(attach_info);
255}
256
258 const char *process_name, const ProcessAttachInfo &attach_info) {
259 return DoAttach(attach_info);
260}
261
263 process_arch = GetArchitecture();
264 // Process::DidExec also comes through Process::CompleteAttach without
265 // resetting the address masks, so they have to be reported again here.
267}
268
270
272
274 void *buf, size_t size, Status &error) {
275 lldb::addr_t addr = process_addr.GetValue();
276 lldb::DataExtractorSP data_extractor_sp =
278
279 if (!data_extractor_sp || !data_extractor_sp->HasData() || error.Fail()) {
280 if (error.Fail()) {
282 "Failed to read memory from scripted process at 0x{0:x-}: {1}", addr,
283 error.AsCString());
284 }
285 return 0;
286 }
287
288 offset_t bytes_copied = data_extractor_sp->CopyByteOrderedData(
289 0, data_extractor_sp->GetByteSize(), buf, size, GetByteOrder());
290
291 if (!bytes_copied || bytes_copied == LLDB_INVALID_OFFSET)
293 LLVM_PRETTY_FUNCTION, "Failed to copy read memory to buffer.", error);
294
295 // FIXME: We should use the diagnostic system to report a warning if the
296 // `bytes_copied` is different from `size`.
297
298 return bytes_copied;
299}
300
301size_t ScriptedProcess::DoWriteMemory(lldb::addr_t vm_addr, const void *buf,
302 size_t size, Status &error) {
303 lldb::DataExtractorSP data_extractor_sp = std::make_shared<DataExtractor>(
304 buf, size, GetByteOrder(), GetAddressByteSize());
305
306 if (!data_extractor_sp || !data_extractor_sp->HasData())
307 return 0;
308
309 lldb::offset_t bytes_written =
310 GetInterface().WriteMemoryAtAddress(vm_addr, data_extractor_sp, error);
311
312 if (!bytes_written || bytes_written == LLDB_INVALID_OFFSET) {
313 if (error.Fail()) {
315 "failed to write memory to scripted process at 0x{0:x-}: {1}",
316 vm_addr, error.AsCString());
317 }
319 LLVM_PRETTY_FUNCTION, "Failed to copy write buffer to memory.", error);
320 }
321
322 // FIXME: We should use the diagnostic system to report a warning if the
323 // `bytes_written` is different from `size`.
324
325 return bytes_written;
326}
327
329 assert(bp_site != nullptr);
330
331 if (IsBreakpointSitePhysicallyEnabled(*bp_site)) {
332 return {};
333 }
334
335 if (bp_site->HardwareRequired()) {
337 "Scripted Processes don't support hardware breakpoints");
338 }
339
342
343 return error;
344}
345
349
351 MemoryRegionInfo &region) {
353 if (auto region_or_err =
354 GetInterface().GetMemoryRegionContainingAddress(load_addr, error))
355 region = *region_or_err;
356
357 return error;
358}
359
362 lldb::addr_t address = 0;
363
364 while (auto region_or_err =
365 GetInterface().GetMemoryRegionContainingAddress(address, error)) {
366 if (error.Fail())
367 break;
368
369 MemoryRegionInfo &mem_region = *region_or_err;
370 auto range = mem_region.GetRange();
371 address += range.GetRangeBase() + range.GetByteSize();
372 region_list.push_back(mem_region);
373 }
374
375 return error;
376}
377
379
381 ThreadList &new_thread_list) {
382 // TODO: Implement
383 // This is supposed to get the current set of threads, if any of them are in
384 // old_thread_list then they get copied to new_thread_list, and then any
385 // actually new threads will get added to new_thread_list.
386 m_thread_plans.ClearThreadCache();
387
390
391 if (!thread_info_sp)
393 LLVM_PRETTY_FUNCTION,
394 "Couldn't fetch thread list from Scripted Process.", error);
395
396 // Because `StructuredData::Dictionary` uses a `std::map<ConstString,
397 // ObjectSP>` for storage, each item is sorted based on the key alphabetical
398 // order. Since `GetThreadsInfo` provides thread indices as the key element,
399 // thread info comes ordered alphabetically, instead of numerically, so we
400 // need to sort the thread indices before creating thread.
401
402 StructuredData::ArraySP keys = thread_info_sp->GetKeys();
403
404 std::map<size_t, StructuredData::ObjectSP> sorted_threads;
405 auto sort_keys = [&sorted_threads,
406 &thread_info_sp](StructuredData::Object *item) -> bool {
407 if (!item)
408 return false;
409
410 llvm::StringRef key = item->GetStringValue();
411 size_t idx = 0;
412
413 // Make sure the provided index is actually an integer
414 if (!llvm::to_integer(key, idx))
415 return false;
416
417 sorted_threads[idx] = thread_info_sp->GetValueForKey(key);
418 return true;
419 };
420
421 size_t thread_count = thread_info_sp->GetSize();
422
423 if (!keys->ForEach(sort_keys) || sorted_threads.size() != thread_count)
424 // Might be worth showing the unsorted thread list instead of return early.
426 LLVM_PRETTY_FUNCTION, "Couldn't sort thread list.", error);
427
428 auto create_scripted_thread =
429 [this, &error, &new_thread_list](
430 const std::pair<size_t, StructuredData::ObjectSP> pair) -> bool {
431 size_t idx = pair.first;
432 StructuredData::ObjectSP object_sp = pair.second;
433
434 if (!object_sp)
436 LLVM_PRETTY_FUNCTION, "Invalid thread info object", error);
437
438 auto thread_or_error =
439 ScriptedThread::Create(*this, object_sp->GetAsGeneric());
440
441 if (!thread_or_error) {
443 llvm::formatv("failed to create scripted thread ({0}): {1}", idx,
444 llvm::toString(thread_or_error.takeError()))
445 .str(),
446 GetTarget().GetDebugger().GetID());
447 return false;
448 }
449
450 ThreadSP thread_sp = thread_or_error.get();
451 lldbassert(thread_sp && "Couldn't initialize scripted thread.");
452
453 RegisterContextSP reg_ctx_sp = thread_sp->GetRegisterContext();
454 if (!reg_ctx_sp)
456 LLVM_PRETTY_FUNCTION,
457 llvm::Twine("Invalid Register Context for thread " + llvm::Twine(idx))
458 .str(),
459 error);
460
461 new_thread_list.AddThread(thread_sp);
462
463 return true;
464 };
465
466 llvm::for_each(sorted_threads, create_scripted_thread);
467
468 return new_thread_list.GetSize(false) > 0;
469}
470
472 // Let all threads recover from stopping and do any clean up based on the
473 // previous thread state (if any).
474 m_thread_list.RefreshStateAfterStop();
475}
476
478 info.Clear();
479 info.SetProcessID(GetID());
482 if (module_sp) {
483 const bool add_exe_file_as_first_arg = false;
484 info.SetExecutableFile(GetTarget().GetExecutableModule()->GetFileSpec(),
485 add_exe_file_as_first_arg);
486 }
487 return true;
488}
489
492 BinaryInformationLevel info_level) {
494 auto error_with_message = [&error](llvm::StringRef message) {
495 return ScriptedInterface::ErrorWithMessage<bool>(LLVM_PRETTY_FUNCTION,
496 message.data(), error);
497 };
498
500
501 if (!loaded_images_sp || !loaded_images_sp->GetSize())
503 LLVM_PRETTY_FUNCTION, "No loaded images.", error);
504
505 ModuleList module_list;
506 Target &target = GetTarget();
507
508 auto reload_image = [&target, &module_list, &error_with_message](
509 StructuredData::Object *obj) -> bool {
511
512 if (!dict)
513 return error_with_message("Couldn't cast image object into dictionary.");
514
515 ModuleSpec module_spec;
516
517 bool has_path = dict->HasKey("path");
518 bool has_uuid = dict->HasKey("uuid");
519 if (!has_path && !has_uuid)
520 return error_with_message("Dictionary should have key 'path' or 'uuid'");
521 if (!dict->HasKey("load_addr"))
522 return error_with_message("Dictionary is missing key 'load_addr'");
523
524 llvm::StringRef path = "";
525 if (has_path) {
526 dict->GetValueForKeyAsString("path", path);
527 module_spec.GetFileSpec().SetPath(path);
528 }
529
530 llvm::StringRef uuid = "";
531 if (has_uuid) {
532 dict->GetValueForKeyAsString("uuid", uuid);
533 module_spec.GetUUID().SetFromStringRef(uuid);
534 }
535
538 dict->GetValueForKeyAsInteger("load_addr", load_addr);
539 dict->GetValueForKeyAsInteger("slide", slide);
540 if (load_addr == LLDB_INVALID_ADDRESS)
541 return error_with_message(
542 "Couldn't get valid load address or slide offset.");
543
544 if (slide != LLDB_INVALID_OFFSET)
545 load_addr += slide;
546
547 module_spec.GetArchitecture() = target.GetArchitecture();
548
549 ModuleSP module_sp =
550 target.GetOrCreateModule(module_spec, true /* notify */);
551
552 bool is_placeholder_module = false;
553
554 if (!module_sp) {
555 // Create a placeholder module
556 LLDB_LOGF(
558 "ScriptedProcess::%s unable to locate the matching "
559 "object file path %s, creating a placeholder module at 0x%" PRIx64,
560 __FUNCTION__, path.str().c_str(), load_addr);
561
563 module_spec, load_addr, module_spec.GetFileSpec().MemorySize());
564
565 is_placeholder_module = true;
566 }
567
568 bool changed = false;
569 module_sp->SetLoadAddress(target, load_addr, false /*=value_is_offset*/,
570 changed);
571
572 if (!changed && !module_sp->GetObjectFile())
573 return error_with_message("Couldn't set the load address for module.");
574
575 FileSpec objfile(path);
576 module_sp->SetFileSpecAndObjectName(objfile,
577 ConstString(objfile.GetFilename()));
578
579 if (is_placeholder_module) {
580 target.GetImages().AppendIfNeeded(module_sp, true /*notify=*/);
581 return true;
582 }
583
584 return module_list.AppendIfNeeded(module_sp);
585 };
586
587 size_t loaded_images_size = loaded_images_sp->GetSize();
588 bool print_error = true;
589 for (size_t idx = 0; idx < loaded_images_size; idx++) {
590 const auto &loaded_image = loaded_images_sp->GetItemAtIndex(idx);
591 if (!reload_image(loaded_image.get()) && print_error) {
592 print_error = false;
594 LLVM_PRETTY_FUNCTION, "Couldn't reload all images.", error);
595 }
596 }
597
598 target.ModulesDidLoad(module_list);
599
600 return loaded_images_sp;
601}
602
605
607 if (!metadata_sp || !metadata_sp->GetSize())
609 LLVM_PRETTY_FUNCTION, "No metadata.", error);
610
611 return metadata_sp;
612}
613
616 for (ThreadSP thread_sp : Threads()) {
617 if (const char *queue_name = thread_sp->GetQueueName()) {
618 QueueSP queue_sp = std::make_shared<Queue>(
619 m_process->shared_from_this(), thread_sp->GetQueueID(), queue_name);
620 m_queue_list.AddQueue(queue_sp);
621 }
622 }
623}
624
629
631 StructuredData::GenericSP object_instance_sp =
633 if (object_instance_sp &&
634 object_instance_sp->GetType() == eStructuredDataTypeGeneric)
635 return object_instance_sp->GetAsGeneric()->GetValue();
636 return nullptr;
637}
static llvm::raw_ostream & error(Stream &strm)
#define lldbassert(x)
Definition LLDBAssert.h:16
#define LLDB_LOGF(log,...)
Definition Log.h:389
#define LLDB_PLUGIN_DEFINE(PluginName)
static constexpr lldb::ScriptLanguage g_supported_script_languages[]
A class which holds the metadata from a remote stub/corefile note about how many bits are used for ad...
void SetAddressableBits(uint32_t addressing_bits)
When a single value is available for the number of bits.
An architecture specification class.
Definition ArchSpec.h:32
Class that manages the actual breakpoint that will be inserted into the running program.
A uniqued constant string class.
Definition ConstString.h:40
static void ReportError(std::string message, std::optional< lldb::user_id_t > debugger_id=std::nullopt, std::once_flag *once=nullptr)
Report error events.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file utility class.
Definition FileSpec.h:56
void SetPath(llvm::StringRef p)
Temporary helper for FileSystem change.
Definition FileSpec.h:286
llvm::StringRef GetFilename() const
Filename string const get accessor.
Definition FileSpec.h:248
size_t MemorySize() const
Get the memory cost of this object.
Definition FileSpec.cpp:420
A collection class for Module objects.
Definition ModuleList.h:125
bool AppendIfNeeded(const lldb::ModuleSP &new_module, bool notify=true)
Append a module to the module list, if it is not already there.
FileSpec & GetFileSpec()
Definition ModuleSpec.h:57
ArchSpec & GetArchitecture()
Definition ModuleSpec.h:93
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:91
static lldb::ModuleSP CreateModuleFromObjectFile(Args &&...args)
Definition Module.h:136
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
An address in a process, qualified by an address space.
lldb::addr_t GetValue() const
void SetExecutableFile(const FileSpec &exe_file, bool add_exe_file_as_first_arg)
void SetArchitecture(const ArchSpec &arch)
Definition ProcessInfo.h:64
void SetProcessID(lldb::pid_t pid)
Definition ProcessInfo.h:68
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
Definition Process.h:552
void SetAddressableBitMasks(AddressableBits bit_masks)
Definition Process.cpp:7129
Process(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp)
Construct with a shared pointer to a target, and the Process listener.
Definition Process.cpp:485
QueueList m_queue_list
The list of libdispatch queues at a given stop point.
Definition Process.h:3499
bool IsBreakpointSitePhysicallyEnabled(const BreakpointSite &site)
Definition Process.cpp:1709
lldb::ByteOrder GetByteOrder() const
Definition Process.cpp:3945
ThreadList::ThreadIterable Threads()
Definition Process.h:2380
ThreadPlanStackMap m_thread_plans
This is the list of thread plans for threads in m_thread_list, as well as threads we knew existed,...
Definition Process.h:3485
friend class Target
Definition Process.h:374
uint32_t GetAddressByteSize() const
Definition Process.cpp:3949
void SetPrivateState(lldb::StateType state)
Definition Process.cpp:1444
virtual void Finalize(bool destructing)
This object is about to be destroyed, do any necessary cleanup.
Definition Process.cpp:596
ThreadList m_thread_list
The threads for this process as the user will see them.
Definition Process.h:3481
lldb::pid_t m_pid
Definition Process.h:3449
friend class ThreadList
Definition Process.h:375
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1267
virtual lldb::ScriptedProcessInterfaceUP CreateScriptedProcessInterface()
static Ret ErrorWithMessage(llvm::StringRef caller_name, llvm::StringRef user_msg, Status &error, LLDBLog log_category=LLDBLog::Process)
StructuredData::GenericSP GetScriptObjectInstance()
virtual lldb::DataExtractorSP ReadMemoryAtAddress(lldb::addr_t address, size_t size, Status &error)
virtual StructuredData::DictionarySP GetThreadsInfo()
virtual Status Attach(const ProcessAttachInfo &attach_info)
virtual bool CreateBreakpoint(lldb::addr_t addr, Status &error)
virtual StructuredData::DictionarySP GetMetadata()
virtual StructuredData::ArraySP GetLoadedImages()
virtual lldb::offset_t WriteMemoryAtAddress(lldb::addr_t addr, lldb::DataExtractorSP data_sp, Status &error)
virtual llvm::Expected< StructuredData::GenericSP > CreatePluginObject(const ScriptedMetadata &scripted_metadata, ExecutionContext &exe_ctx, StructuredData::Generic *script_obj=nullptr)=0
Status DoAttachToProcessWithID(lldb::pid_t pid, const ProcessAttachInfo &attach_info) override
Attach to an existing process using a process ID.
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
bool DoUpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
const ScriptedMetadata m_scripted_metadata
size_t DoReadMemory(const ProcessAddress &addr, void *buf, size_t size, Status &error) override
Actually do the reading of memory from a process.
void DidAttach(ArchSpec &process_arch) override
Called after attaching a process.
static llvm::StringRef GetPluginNameStatic()
Status GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list) override
Obtain all the mapped memory regions within this process.
static bool IsScriptLanguageSupported(lldb::ScriptLanguage language)
bool IsAlive() override
Check if a process is still alive.
Status DoAttach(const ProcessAttachInfo &attach_info)
bool GetProcessInfo(ProcessInstanceInfo &info) override
lldb_private::StructuredData::ObjectSP GetLoadedDynamicLibrariesInfos(lldb::BinaryInformationLevel info_level) override
Retrieve a StructuredData dictionary about all of the binaries loaded in the process at this time.
void DidResume() override
Called after resuming a process.
Status DoLaunch(Module *exe_module, ProcessLaunchInfo &launch_info) override
Launch a new process.
size_t DoWriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Status &error) override
Actually do the writing of memory to a process.
Status DoResume(lldb::RunDirection direction) override
Resumes all of a process's threads as configured using the Thread run control functions.
ScriptedProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const ScriptedMetadata &scripted_metadata, Status &error)
lldb::ScriptedProcessInterfaceUP m_interface_up
llvm::StringRef GetPluginName() override
Status EnableBreakpointSite(BreakpointSite *bp_site) override
lldb_private::StructuredData::DictionarySP GetMetadata() override
Fetch process defined metadata.
Status DoAttachToProcessWithName(const char *process_name, const ProcessAttachInfo &attach_info) override
Attach to an existing process using a partial process name.
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec *crash_file_path, bool can_connect)
static llvm::StringRef GetPluginDescriptionStatic()
ScriptedProcessInterface & GetInterface() const
void DidLaunch() override
Called after launching a process.
void DidLaunchOrAttach()
Pick up the process state that has to be in place before the first stop is reported,...
Status DoGetMemoryRegionInfo(lldb::addr_t load_addr, MemoryRegionInfo &range_info) override
DoGetMemoryRegionInfo is called by GetMemoryRegionInfo after it has removed non address bits from loa...
static llvm::Expected< std::shared_ptr< ScriptedThread > > Create(ScriptedProcess &process, StructuredData::Generic *script_object=nullptr)
An error handling class.
Definition Status.h:118
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition Status.cpp:106
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status static Status FromErrorStringWithFormatv(const char *format, Args &&...args)
Definition Status.h:151
virtual lldb::addr_t GetLoadAddress() const
bool GetValueForKeyAsInteger(llvm::StringRef key, IntType &result) const
bool GetValueForKeyAsString(llvm::StringRef key, llvm::StringRef &result) const
bool HasKey(llvm::StringRef key) const
std::shared_ptr< Generic > GenericSP
std::shared_ptr< Dictionary > DictionarySP
std::shared_ptr< Object > ObjectSP
std::shared_ptr< Array > ArraySP
const ProcessLaunchInfo & GetProcessLaunchInfo() const
Definition Target.cpp:5877
void ModulesDidLoad(ModuleList &module_list)
This call may preload module symbols, and may do so in parallel depending on the following target set...
Definition Target.cpp:1961
lldb::ModuleSP GetOrCreateModule(const ModuleSpec &module_spec, bool notify, Status *error_ptr=nullptr)
Find a binary on the system and return its Module, or return an existing Module that is already in th...
Definition Target.cpp:2470
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition Target.cpp:1630
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition Target.h:1273
const ArchSpec & GetArchitecture() const
Definition Target.h:1315
void AddThread(const lldb::ThreadSP &thread_sp)
uint32_t GetSize(bool can_update=true)
bool SetFromStringRef(llvm::StringRef str)
Definition UUID.cpp:101
#define LLDB_INVALID_ADDRESS
#define LLDB_INVALID_OFFSET
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:338
static uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit)
Definition ARMUtils.h:265
ScriptLanguage
Script interpreter types.
@ eScriptLanguagePython
std::shared_ptr< lldb_private::Queue > QueueSP
RunDirection
Execution directions.
std::shared_ptr< lldb_private::Thread > ThreadSP
uint64_t offset_t
Definition lldb-types.h:86
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateRunning
Process or thread is running and can't be examined.
std::shared_ptr< lldb_private::Process > ProcessSP
uint64_t pid_t
Definition lldb-types.h:84
std::shared_ptr< lldb_private::Listener > ListenerSP
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
@ eStructuredDataTypeGeneric
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP