LLDB mainline
ProcessFreeBSDKernelCore.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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 "lldb/Core/Module.h"
14#include "lldb/Symbol/Type.h"
17#include "lldb/Utility/Log.h"
19
23
24using namespace lldb;
25using namespace lldb_private;
26
28
29namespace {
30
31#define LLDB_PROPERTIES_processfreebsdkernelcore
32#include "ProcessFreeBSDKernelCoreProperties.inc"
33
34enum {
35#define LLDB_PROPERTIES_processfreebsdkernelcore
36#include "ProcessFreeBSDKernelCorePropertiesEnum.inc"
37};
38
39class PluginProperties : public Properties {
40public:
41 static llvm::StringRef GetSettingName() {
43 }
44
45 PluginProperties() : Properties() {
46 m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName());
47 m_collection_sp->Initialize(g_processfreebsdkernelcore_properties_def);
48 }
49
50 ~PluginProperties() override = default;
51
52 bool GetReadOnly() const {
53 const uint32_t idx = ePropertyReadOnly;
54 return GetPropertyAtIndexAs<bool>(idx, true);
55 }
56};
57
58} // namespace
59
60static PluginProperties &GetGlobalPluginProperties() {
61 static PluginProperties g_settings;
62 return g_settings;
63}
64
66 : public CommandObjectParsed {
67public:
69 CommandInterpreter &interpreter)
71 interpreter, "process plugin refresh-threads",
72 "Refresh the thread list from the FreeBSD kernel core. The thread "
73 "list and related data structures may be being read from live "
74 "memory (/dev/mem), which may have changed since the last refresh. "
75 "This command clears LLDB's thread list and memory cache then "
76 "re-reads the kernel's allproc/zombie lists to rebuild the thread "
77 "list from scratch.",
78 "process plugin refresh-threads",
79 eCommandRequiresProcess | eCommandTryTargetAPILock) {}
80
82
83protected:
84 void DoExecute(Args &command, CommandReturnObject &result) override {
85 // TODO: Return early for elf-core based implementation.
86
87 auto process = static_cast<ProcessFreeBSDKernelCore *>(
88 m_interpreter.GetExecutionContext().GetProcessPtr());
89
90 // Clear the memory cache so DoUpdateThreadList() will re-read allproc,
91 // zombproc, and all thread/proc structures fresh from the core dump instead
92 // of getting stale cached values.
93 process->m_memory_cache.Clear();
94
95 // Clear both thread lists to guarantee that UpdateThreadListIfNeeded() sees
96 // size == 0 and enters the rebuild path regardless of stop-ID state.
97 // UpdateThreadListIfNeeded() passes m_thread_list_real as old_thread_list
98 // to DoUpdateThreadList(), and DoUpdateThreadList() only rebuilds from
99 // scratch when old_thread_list is empty. m_thread_list is the public copy
100 // that is sync'd from m_thread_list_real afterwards.
101 process->m_thread_list_real.Clear();
102 process->m_thread_list.Clear();
103
104 // This calls UpdateThreadListIfNeeded() to rebuild the process thread list.
105 const uint32_t num_threads =
106 process->GetThreadList().GetSize(/*can_update=*/true);
108 "Thread list refreshed, {0} thread{1} found.", num_threads,
109 num_threads == 1 ? "" : "s");
111 }
112};
113
115 ListenerSP listener_sp,
116 const FileSpec &core_file)
117 : PostMortemProcess(target_sp, listener_sp, core_file) {}
118
120 m_thread_list.Clear();
121
122 // We need to call finalize on the process before destroying ourselves to
123 // make sure all of the broadcaster cleanup goes as planned. If we destruct
124 // this class, then Process::~Process() might have problems trying to fully
125 // destroy the broadcaster.
126 Finalize(/*destructing=*/true);
127}
128
130 lldb::TargetSP target_sp, ListenerSP listener_sp,
131 const FileSpec *crash_file, bool can_connect) {
132 ModuleSP executable = target_sp->GetExecutableModule();
133 if (crash_file && !can_connect && executable) {
134 kvm_t *kvm =
135 kvm_open2(executable->GetFileSpec().GetPath().c_str(),
136 crash_file->GetPath().c_str(), O_RDONLY, nullptr, nullptr);
137 if (kvm) {
138 kvm_close(kvm);
139 return std::make_shared<ProcessFreeBSDKernelCore>(target_sp, listener_sp,
140 *crash_file);
141 }
142 }
143 return nullptr;
144}
145
151
154 debugger, PluginProperties::GetSettingName())) {
155 const bool is_global_setting = true;
158 "Properties for the freebsd-kernel process plug-in.",
159 is_global_setting);
160 }
161}
162
166
168 bool plugin_specified_by_name) {
169 return true;
170}
171
173 if (!m_command_sp) {
174 CommandInterpreter &interp =
176 m_command_sp = std::make_unique<CommandObjectMultiword>(
177 interp, "process plugin",
178 "Commands for the FreeBSD kernel process plug-in.",
179 "process plugin <subcommand> [<subcommand-options>]");
180 m_command_sp->LoadSubCommand(
181 "refresh-threads",
184 }
185 return m_command_sp.get();
186}
187
189 ModuleSP executable = GetTarget().GetExecutableModule();
190 if (!executable)
192 "ProcessFreeBSDKernelCore: no executable module set on target");
193
194 m_kvm = kvm_open2(executable->GetFileSpec().GetPath().c_str(),
195 GetCoreFile().GetPath().c_str(), O_RDWR, nullptr, nullptr);
196
197 if (!m_kvm)
199 "ProcessFreeBSDKernelCore: kvm_open2 failed for core '%s' "
200 "with kernel '%s'",
201 GetCoreFile().GetPath().c_str(),
202 executable->GetFileSpec().GetPath().c_str());
203
205
206 return Status();
207}
208
215
217 if (!m_kvm)
218 return Status::FromErrorString("kvm file descriptor is not set.");
219
220 kvm_close(m_kvm);
221 return Status();
222}
223
230
232 const void *buf, size_t size,
233 Status &error) {
234 if (GetGlobalPluginProperties().GetReadOnly()) {
236 "Memory writes are currently disabled. You can enable them with "
237 "`settings set plugin.process.freebsd-kernel-core.read-only false`.");
238 return 0;
239 }
240
241 ssize_t rd = 0;
242 rd = kvm_write(m_kvm, addr, buf, size);
243 if (rd < 0 || static_cast<size_t>(rd) != size) {
244 error = Status::FromErrorStringWithFormat("Writing memory failed: %s",
245 GetError());
246 return rd > 0 ? rd : 0;
247 }
248 return rd;
249}
250
252 ThreadList &new_thread_list) {
253 if (old_thread_list.GetSize(false) == 0) {
254 // Make up the thread the first time this is called so we can set our one
255 // and only core thread state up.
256
257 // We cannot construct a thread without a register context as that crashes
258 // LLDB but we can construct a process without threads to provide minimal
259 // memory reading support.
260 switch (GetTarget().GetArchitecture().GetMachine()) {
261 case llvm::Triple::arm:
262 case llvm::Triple::aarch64:
263 case llvm::Triple::ppc64le:
264 case llvm::Triple::riscv64:
265 case llvm::Triple::x86:
266 case llvm::Triple::x86_64:
267 break;
268 default:
269 return false;
270 }
271
273
274 // struct field offsets are written as symbols so that we don't have
275 // to figure them out ourselves
276 int32_t offset_p_list = ReadSignedIntegerFromMemory(
277 FindSymbol("proc_off_p_list"), 4, -1, error);
278 int32_t offset_p_pid =
279 ReadSignedIntegerFromMemory(FindSymbol("proc_off_p_pid"), 4, -1, error);
280 int32_t offset_p_threads = ReadSignedIntegerFromMemory(
281 FindSymbol("proc_off_p_threads"), 4, -1, error);
282 int32_t offset_p_comm = ReadSignedIntegerFromMemory(
283 FindSymbol("proc_off_p_comm"), 4, -1, error);
284
285 int32_t offset_td_tid = ReadSignedIntegerFromMemory(
286 FindSymbol("thread_off_td_tid"), 4, -1, error);
287 int32_t offset_td_plist = ReadSignedIntegerFromMemory(
288 FindSymbol("thread_off_td_plist"), 4, -1, error);
289 int32_t offset_td_pcb = ReadSignedIntegerFromMemory(
290 FindSymbol("thread_off_td_pcb"), 4, -1, error);
291 int32_t offset_td_oncpu = ReadSignedIntegerFromMemory(
292 FindSymbol("thread_off_td_oncpu"), 4, -1, error);
293 int32_t offset_td_name = ReadSignedIntegerFromMemory(
294 FindSymbol("thread_off_td_name"), 4, -1, error);
295
296 // Fail if we were not able to read any of the offsets.
297 if (offset_p_list == -1 || offset_p_pid == -1 || offset_p_threads == -1 ||
298 offset_p_comm == -1 || offset_td_tid == -1 || offset_td_plist == -1 ||
299 offset_td_pcb == -1 || offset_td_oncpu == -1 || offset_td_name == -1)
300 return false;
301
302 // dumptid contains the thread-id of the crashing thread
303 // dumppcb contains its PCB
304 int32_t dumptid =
305 ReadSignedIntegerFromMemory(FindSymbol("dumptid"), 4, -1, error);
306 lldb::addr_t dumppcb = FindSymbol("dumppcb");
307
308 // stoppcbs is an array of PCBs on all CPUs.
309 // Each element is of size pcb_size.
310 int32_t pcbsize =
311 ReadSignedIntegerFromMemory(FindSymbol("pcb_size"), 4, -1, error);
312 lldb::addr_t stoppcbs = FindSymbol("stoppcbs");
313
314 // Read stopped_cpus bitmask and mp_maxid for CPU validation.
315 lldb::addr_t stopped_cpus = FindSymbol("stopped_cpus");
316 uint32_t mp_maxid = 0;
317
318 if (stopped_cpus != LLDB_INVALID_ADDRESS) {
319 // https://cgit.freebsd.org/src/tree/sys/kern/subr_smp.c
320 mp_maxid =
321 ReadSignedIntegerFromMemory(FindSymbol("mp_maxid"), 4, 0, error);
322 if (error.Fail())
323 stopped_cpus = LLDB_INVALID_ADDRESS;
324 }
325
326 uint32_t long_size_bytes = GetAddressByteSize();
327 uint32_t long_bit = long_size_bytes * 8;
328
329 if (auto type_system_or_err =
330 GetTarget().GetScratchTypeSystemForLanguage(eLanguageTypeC)) {
331 CompilerType long_type =
332 (*type_system_or_err)->GetBasicTypeFromAST(eBasicTypeLong);
333 if (long_type.IsValid())
334 if (auto size = long_type.GetByteSize(nullptr))
335 long_size_bytes = *size;
336 long_bit = long_size_bytes * 8;
337 } else
338 llvm::consumeError(type_system_or_err.takeError());
339
340 // https://cgit.freebsd.org/src/tree/sys/sys/param.h
341 constexpr size_t fbsd_maxcomlen = 19;
342
343 // Iterate through a linked list of all processes. New processes are added
344 // to the head of this list. Which means that earlier PIDs are actually at
345 // the end of the list, so we have to walk it backwards. First collect all
346 // the processes in the list order.
347 std::vector<lldb::addr_t> process_addrs;
348 if (lldb::addr_t allproc_addr = FindSymbol("allproc");
349 allproc_addr != LLDB_INVALID_ADDRESS) {
350 for (lldb::addr_t proc = ReadPointerFromMemory(allproc_addr, error);
351 proc != 0 && proc != LLDB_INVALID_ADDRESS && error.Success();
352 proc = ReadPointerFromMemory(proc + offset_p_list, error))
353 process_addrs.push_back(proc);
354 }
355
356 // Processes are in the linked list in descending PID order, so we must walk
357 // them in reverse to get ascending PID order.
358 for (auto proc_it = process_addrs.rbegin(); proc_it != process_addrs.rend();
359 ++proc_it) {
360 lldb::addr_t proc = *proc_it;
361 int32_t pid =
362 ReadSignedIntegerFromMemory(proc + offset_p_pid, 4, -1, error);
363 // process' command-line string
364 char comm[fbsd_maxcomlen + 1];
365 ReadCStringFromMemory(proc + offset_p_comm, comm, sizeof(comm), error);
366
367 // Iterate through a linked list of all process' threads
368 // the initial thread is found in process' p_threads, subsequent
369 // elements are linked via td_plist field
370 for (lldb::addr_t td =
371 ReadPointerFromMemory(proc + offset_p_threads, error);
372 td != 0; td = ReadPointerFromMemory(td + offset_td_plist, error)) {
373 int32_t tid =
374 ReadSignedIntegerFromMemory(td + offset_td_tid, 4, -1, error);
375 lldb::addr_t pcb_addr =
376 ReadPointerFromMemory(td + offset_td_pcb, error);
377 // whether process was on CPU (-1 if not, otherwise CPU number)
378 int32_t oncpu =
379 ReadSignedIntegerFromMemory(td + offset_td_oncpu, 4, -2, error);
380 // thread name
381 char thread_name[fbsd_maxcomlen + 1];
382 ReadCStringFromMemory(td + offset_td_name, thread_name,
383 sizeof(thread_name), error);
384
385 // If we failed to read TID, ignore this thread.
386 if (tid == -1)
387 continue;
388
389 std::string thread_desc = llvm::formatv("(pid {0}) {1}", pid, comm);
390 if (*thread_name && strcmp(thread_name, comm)) {
391 thread_desc += '/';
392 thread_desc += thread_name;
393 }
394
395 // Roughly:
396 // 1. if the thread crashed, its PCB is going to be at "dumppcb"
397 // 2. if the thread was on CPU, its PCB is going to be on the CPU
398 // 3. otherwise, its PCB is in the thread struct
399 if (tid == dumptid) {
400 // NB: dumppcb can be LLDB_INVALID_ADDRESS if reading it failed
401 pcb_addr = dumppcb;
402 thread_desc += " (crashed)";
403 } else if (oncpu != -1) {
404 // Verify the CPU is actually in the stopped set before using
405 // its stoppcbs entry.
406 bool is_stopped = false;
407 if (oncpu >= 0 && static_cast<uint32_t>(oncpu) <= mp_maxid &&
408 stopped_cpus != LLDB_INVALID_ADDRESS) {
409 uint32_t bit = oncpu % long_bit;
410 uint32_t word = oncpu / long_bit;
411 lldb::addr_t mask_addr = stopped_cpus + word * long_size_bytes;
412 uint64_t mask = ReadUnsignedIntegerFromMemory(
413 mask_addr, long_size_bytes, 0, error);
414 if (error.Success())
415 is_stopped = (mask & (1ULL << bit)) != 0;
416 }
417
418 // If we managed to read stoppcbs and pcb_size and the cpu is marked
419 // as stopped, use them to find the correct PCB.
420 if (is_stopped && stoppcbs != LLDB_INVALID_ADDRESS && pcbsize > 0) {
421 pcb_addr = stoppcbs + oncpu * pcbsize;
422 } else {
423 pcb_addr = LLDB_INVALID_ADDRESS;
424 }
425 thread_desc += llvm::formatv(" (on CPU {0})", oncpu);
426 }
427
428 auto thread =
429 new ThreadFreeBSDKernelCore(*this, tid, pcb_addr, thread_desc);
430
431 if (tid == dumptid)
432 thread->SetIsCrashedThread(true);
433
434 new_thread_list.AddThread(static_cast<ThreadSP>(thread));
435 }
436 }
437 } else {
438 const uint32_t num_threads = old_thread_list.GetSize(false);
439 for (uint32_t i = 0; i < num_threads; ++i)
440 new_thread_list.AddThread(old_thread_list.GetThreadAtIndex(i, false));
441 }
442 return new_thread_list.GetSize(false) > 0;
443}
444
446 size_t size, Status &error) {
447 ssize_t rd = 0;
448 rd = kvm_read2(m_kvm, addr, buf, size);
449 if (rd < 0 || static_cast<size_t>(rd) != size) {
450 error = Status::FromErrorStringWithFormat("Reading memory failed: %s",
451 GetError());
452 return rd > 0 ? rd : 0;
453 }
454 return rd;
455}
456
459 const Symbol *sym = mod_sp->FindFirstSymbolWithNameAndType(ConstString(name));
460 return sym ? sym->GetLoadAddress(&GetTarget()) : LLDB_INVALID_ADDRESS;
461}
462
464 kssize_t displacement = kvm_kerndisp(m_kvm);
465
466 if (displacement == 0)
467 return;
468
469 Target &target = GetTarget();
470 lldb::ModuleSP kernel_module_sp = target.GetExecutableModule();
471 if (!kernel_module_sp)
472 return;
473
474 bool changed = false;
475 kernel_module_sp->SetLoadAddress(target,
476 static_cast<lldb::addr_t>(displacement),
477 /*value_is_offset=*/true, changed);
478
479 if (changed) {
480 ModuleList loaded_module_list;
481 loaded_module_list.Append(kernel_module_sp);
482 target.ModulesDidLoad(loaded_module_list);
483 }
484}
485
487 Target &target = GetTarget();
488 Debugger &debugger = target.GetDebugger();
489
491
492 // Find msgbufp symbol (pointer to message buffer)
493 lldb::addr_t msgbufp_addr = FindSymbol("msgbufp");
494 if (msgbufp_addr == LLDB_INVALID_ADDRESS)
495 return;
496
497 // Read the pointer value
498 lldb::addr_t msgbufp = ReadPointerFromMemory(msgbufp_addr, error);
499 if (!error.Success() || msgbufp == LLDB_INVALID_ADDRESS)
500 return;
501
502 // Get the type information for struct msgbuf from DWARF
503 TypeQuery query("msgbuf");
504 TypeResults results;
505 target.GetImages().FindTypes(nullptr, query, results);
506
507 uint64_t offset_msg_ptr = 0;
508 uint64_t offset_msg_size = 0;
509 uint64_t offset_msg_wseq = 0;
510 uint64_t offset_msg_rseq = 0;
511
512 if (results.GetTypeMap().GetSize() > 0) {
513 // Found type info - use it to get field offsets
514 CompilerType msgbuf_type =
515 results.GetTypeMap().GetTypeAtIndex(0)->GetForwardCompilerType();
516
517 uint32_t num_fields = msgbuf_type.GetNumFields();
518 int field_found = 0;
519 for (uint32_t i = 0; i < num_fields; i++) {
520 std::string field_name;
521 uint64_t field_offset = 0;
522
523 msgbuf_type.GetFieldAtIndex(i, field_name, &field_offset, nullptr,
524 nullptr);
525
526 if (field_name == "msg_ptr") {
527 offset_msg_ptr = field_offset / 8; // Convert bits to bytes
528 field_found++;
529 } else if (field_name == "msg_size") {
530 offset_msg_size = field_offset / 8;
531 field_found++;
532 } else if (field_name == "msg_wseq") {
533 offset_msg_wseq = field_offset / 8;
534 field_found++;
535 } else if (field_name == "msg_rseq") {
536 offset_msg_rseq = field_offset / 8;
537 field_found++;
538 }
539 }
540
541 if (field_found != 4) {
542 LLDB_LOGF(
544 "FreeBSD-Kernel-Core: Could not find all required fields for msgbuf");
545 return;
546 }
547 } else {
548 // Fallback: use hardcoded offsets based on struct layout
549 // struct msgbuf layout (from sys/sys/msgbuf.h):
550 // char *msg_ptr; - offset 0
551 // u_int msg_magic; - offset ptr_size
552 // u_int msg_size; - offset ptr_size + 4
553 // u_int msg_wseq; - offset ptr_size + 8
554 // u_int msg_rseq; - offset ptr_size + 12
555 uint32_t ptr_size = GetAddressByteSize();
556 offset_msg_ptr = 0;
557 offset_msg_size = ptr_size + 4;
558 offset_msg_wseq = ptr_size + 8;
559 offset_msg_rseq = ptr_size + 12;
560 }
561
562 // Read struct msgbuf fields
563 lldb::addr_t bufp = ReadPointerFromMemory(msgbufp + offset_msg_ptr, error);
564 if (!error.Success() || bufp == LLDB_INVALID_ADDRESS)
565 return;
566
567 uint32_t size =
568 ReadUnsignedIntegerFromMemory(msgbufp + offset_msg_size, 4, 0, error);
569 if (!error.Success() || size == 0)
570 return;
571
572 uint32_t wseq =
573 ReadUnsignedIntegerFromMemory(msgbufp + offset_msg_wseq, 4, 0, error);
574 if (!error.Success())
575 return;
576
577 uint32_t rseq =
578 ReadUnsignedIntegerFromMemory(msgbufp + offset_msg_rseq, 4, 0, error);
579 if (!error.Success())
580 return;
581
582 // Convert sequences to positions
583 // MSGBUF_SEQ_TO_POS macro in FreeBSD: ((seq) % (size))
584 uint32_t rseq_pos = rseq % size;
585 uint32_t wseq_pos = wseq % size;
586
587 if (rseq_pos == wseq_pos)
588 return;
589
590 // Print crash info at once using stream
591 lldb::StreamSP stream_sp = debugger.GetAsyncOutputStream();
592 if (!stream_sp)
593 return;
594
595 stream_sp->PutCString("\nUnread portion of the kernel message buffer:\n");
596
597 // Read ring buffer in at most two chunks
598 if (rseq_pos < wseq_pos) {
599 // No wrap: read from rseq_pos to wseq_pos
600 size_t len = wseq_pos - rseq_pos;
601 std::string buf(len, '\0');
602 size_t bytes_read = ReadMemory(bufp + rseq_pos, &buf[0], len, error);
603 if (error.Success() && bytes_read > 0) {
604 buf.resize(bytes_read);
605 *stream_sp << buf;
606 }
607 } else {
608 // Wrap around: read from rseq_pos to end, then from start to wseq_pos
609 size_t len1 = size - rseq_pos;
610 std::string buf1(len1, '\0');
611 size_t bytes_read1 = ReadMemory(bufp + rseq_pos, &buf1[0], len1, error);
612 if (error.Success() && bytes_read1 > 0) {
613 buf1.resize(bytes_read1);
614 *stream_sp << buf1;
615 }
616
617 if (wseq_pos > 0) {
618 std::string buf2(wseq_pos, '\0');
619 size_t bytes_read2 = ReadMemory(bufp, &buf2[0], wseq_pos, error);
620 if (error.Success() && bytes_read2 > 0) {
621 buf2.resize(bytes_read2);
622 *stream_sp << buf2;
623 }
624 }
625 }
626
627 stream_sp->PutChar('\n');
628 stream_sp->Flush();
629}
630
631const char *ProcessFreeBSDKernelCore::GetError() { return kvm_geterr(m_kvm); }
static llvm::raw_ostream & error(Stream &strm)
#define bit
static PluginProperties & GetGlobalPluginProperties()
#define LLDB_LOGF(log,...)
Definition Log.h:378
#define LLDB_PLUGIN_DEFINE(PluginName)
static PluginProperties & GetGlobalPluginProperties()
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessFreeBSDKernelCoreRefreshThreads(CommandInterpreter &interpreter)
~CommandObjectProcessFreeBSDKernelCoreRefreshThreads() override=default
static llvm::StringRef GetPluginNameStatic()
lldb_private::Status DoDestroy() override
static llvm::StringRef GetPluginNameStatic()
ProcessFreeBSDKernelCore(lldb::TargetSP target_sp, lldb::ListenerSP listener, const lldb_private::FileSpec &core_file)
lldb::addr_t FindSymbol(const char *name)
size_t DoReadMemory(lldb::addr_t addr, void *buf, size_t size, lldb_private::Status &error) override
Actually do the reading of memory from a process.
static lldb::ProcessSP CreateInstance(lldb::TargetSP target_sp, lldb::ListenerSP listener, const lldb_private::FileSpec *crash_file_path, bool can_connect)
void RefreshStateAfterStop() override
Currently called as part of ShouldStop.
static void DebuggerInitialize(lldb_private::Debugger &debugger)
static llvm::StringRef GetPluginDescriptionStatic()
lldb_private::Status DoLoadCore() override
lldb_private::CommandObject * GetPluginCommandObject() override
Return a multi-word command object that can be used to expose plug-in specific commands.
friend class CommandObjectProcessFreeBSDKernelCoreRefreshThreads
lldb_private::DynamicLoader * GetDynamicLoader() override
Get the dynamic loader plug-in for this process.
size_t DoWriteMemory(lldb::addr_t addr, const void *buf, size_t size, lldb_private::Status &error) override
Actually do the writing of memory to a process.
bool DoUpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list) override
Update the thread list following process plug-in's specific logic.
bool CanDebug(lldb::TargetSP target_sp, bool plugin_specified_by_name) override
Check if a plug-in instance can debug the file in module.
std::unique_ptr< lldb_private::CommandObjectMultiword > m_command_sp
A command line argument class.
Definition Args.h:33
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
CommandInterpreter & m_interpreter
void SetStatus(lldb::ReturnStatus status)
void void AppendMessageWithFormatv(const char *format, Args &&...args)
Generic representation of a type in a programming language.
CompilerType GetBasicTypeFromAST(lldb::BasicType basic_type) const
Create related types using the current type's AST.
CompilerType GetFieldAtIndex(size_t idx, std::string &name, uint64_t *bit_offset_ptr, uint32_t *bitfield_bit_size_ptr, bool *is_bitfield_ptr) const
llvm::Expected< uint64_t > GetByteSize(ExecutionContextScope *exe_scope) const
Return the size of the type in bytes.
uint32_t GetNumFields() const
A uniqued constant string class.
Definition ConstString.h:40
CommandInterpreter & GetCommandInterpreter()
Definition Debugger.h:189
lldb::StreamUP GetAsyncOutputStream()
static DynamicLoader * FindPlugin(Process *process, llvm::StringRef plugin_name)
Find a dynamic loader plugin for a given process.
A file utility class.
Definition FileSpec.h:57
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
Definition FileSpec.cpp:374
void Clear(bool clear_invalid_ranges=false)
Definition Memory.cpp:32
A collection class for Module objects.
Definition ModuleList.h:125
void FindTypes(Module *search_first, const TypeQuery &query, lldb_private::TypeResults &results) const
Find types using a type-matching object that contains all search parameters.
void Append(const lldb::ModuleSP &module_sp, bool notify=true)
Append a module to the module list.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool CreateSettingForProcessPlugin(Debugger &debugger, const lldb::OptionValuePropertiesSP &properties_sp, llvm::StringRef description, bool is_global_property)
static lldb::OptionValuePropertiesSP GetSettingForProcessPlugin(Debugger &debugger, llvm::StringRef setting_name)
static bool UnregisterPlugin(ABICreateInstance create_callback)
PostMortemProcess(lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, const FileSpec &core_file)
FileSpec GetCoreFile() const override
Provide a way to retrieve the core dump file that is loaded for debugging.
int64_t ReadSignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, int64_t fail_value, Status &error)
Definition Process.cpp:2359
size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr, size_t cstr_max_len, Status &error)
Read a NULL terminated C string from memory.
Definition Process.cpp:2190
lldb::DynamicLoaderUP m_dyld_up
Definition Process.h:3410
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition Process.cpp:1904
uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error)
Reads an unsigned integer of the specified byte size from process memory.
Definition Process.cpp:2309
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
Definition Process.cpp:2370
friend class Target
Definition Process.h:360
MemoryCache m_memory_cache
Definition Process.h:3433
uint32_t GetAddressByteSize() const
Definition Process.cpp:3767
virtual void Finalize(bool destructing)
This object is about to be destroyed, do any necessary cleanup.
Definition Process.cpp:535
ThreadList m_thread_list
The threads for this process as the user will see them.
Definition Process.h:3383
friend class DynamicLoader
Definition Process.h:357
friend class Debugger
Definition Process.h:356
friend class ThreadList
Definition Process.h:361
Target & GetTarget()
Get the target object pointer for this module.
Definition Process.h:1250
lldb::OptionValuePropertiesSP GetValueProperties() const
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
lldb::addr_t GetLoadAddress(Target *target) const
Definition Symbol.cpp:504
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:1841
Debugger & GetDebugger() const
Definition Target.h:1240
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition Target.cpp:1525
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition Target.h:1157
void AddThread(const lldb::ThreadSP &thread_sp)
uint32_t GetSize(bool can_update=true)
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
uint32_t GetSize() const
Definition TypeMap.cpp:75
lldb::TypeSP GetTypeAtIndex(uint32_t idx)
Definition TypeMap.cpp:83
A class that contains all state required for type lookups.
Definition Type.h:104
This class tracks the state and results of a TypeQuery.
Definition Type.h:344
TypeMap & GetTypeMap()
Definition Type.h:386
#define LLDB_INVALID_ADDRESS
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:327
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
@ eLanguageTypeC
Non-standardized C, such as K&R.
std::shared_ptr< lldb_private::Stream > StreamSP
std::shared_ptr< lldb_private::Process > ProcessSP
@ eReturnStatusSuccessFinishResult
std::shared_ptr< lldb_private::Listener > ListenerSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP