LLDB mainline
CommandObjectProcess.cpp
Go to the documentation of this file.
1//===-- CommandObjectProcess.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
11#include "CommandObjectTrace.h"
19#include "lldb/Core/Module.h"
29#include "lldb/Target/Process.h"
31#include "lldb/Target/Target.h"
32#include "lldb/Target/Thread.h"
34#include "lldb/Utility/Args.h"
36#include "lldb/Utility/State.h"
37
38#include "llvm/ADT/ScopeExit.h"
39
40#include <bitset>
41#include <optional>
42
43using namespace lldb;
44using namespace lldb_private;
45
47public:
49 const char *name, const char *help,
50 const char *syntax, uint32_t flags,
51 const char *new_process_action)
52 : CommandObjectParsed(interpreter, name, help, syntax, flags),
53 m_new_process_action(new_process_action) {}
54
56
57protected:
59 CommandReturnObject &result) {
60 state = eStateInvalid;
61 if (process) {
62 state = process->GetState();
63
64 if (process->IsAlive() && state != eStateConnected) {
65 std::string message;
66 if (process->GetState() == eStateAttaching)
67 message =
68 llvm::formatv("There is a pending attach, abort it and {0}?",
70 else if (process->GetShouldDetach())
71 message = llvm::formatv(
72 "There is a running process, detach from it and {0}?",
74 else
75 message =
76 llvm::formatv("There is a running process, kill it and {0}?",
78
79 if (!m_interpreter.Confirm(message, true)) {
81 return false;
82 } else {
83 if (process->GetShouldDetach()) {
84 bool keep_stopped = false;
85 Status detach_error(process->Detach(keep_stopped));
86 if (detach_error.Success()) {
88 process = nullptr;
89 } else {
91 "Failed to detach from process: %s\n",
92 detach_error.AsCString());
93 }
94 } else {
95 Status destroy_error(process->Destroy(false));
96 if (destroy_error.Success()) {
98 process = nullptr;
99 } else {
100 result.AppendErrorWithFormat("Failed to kill process: %s\n",
101 destroy_error.AsCString());
102 }
103 }
104 }
105 }
106 }
107 return result.Succeeded();
108 }
109
111};
112
113// CommandObjectProcessLaunch
114#pragma mark CommandObjectProcessLaunch
116public:
119 interpreter, "process launch",
120 "Launch the executable in the debugger.", nullptr,
121 eCommandRequiresTarget, "restart"),
122
123 m_class_options("scripted process", true, 'C', 'k', 'v', 0) {
128
130 }
131
132 ~CommandObjectProcessLaunch() override = default;
133
134 Options *GetOptions() override { return &m_all_options; }
135
136 std::optional<std::string> GetRepeatCommand(Args &current_command_args,
137 uint32_t index) override {
138 // No repeat for "process launch"...
139 return std::string("");
140 }
141
142protected:
143 void DoExecute(Args &launch_args, CommandReturnObject &result) override {
144 Debugger &debugger = GetDebugger();
145 Target *target = debugger.GetSelectedTarget().get();
146 // If our listener is nullptr, users aren't allows to launch
147 ModuleSP exe_module_sp = target->GetExecutableModule();
148
149 // If the target already has an executable module, then use that. If it
150 // doesn't then someone must be trying to launch using a path that will
151 // make sense to the remote stub, but doesn't exist on the local host.
152 // In that case use the ExecutableFile that was set in the target's
153 // ProcessLaunchInfo.
154 if (exe_module_sp == nullptr && !target->GetProcessLaunchInfo().GetExecutableFile()) {
155 result.AppendError("no file in target, create a debug target using the "
156 "'target create' command");
157 return;
158 }
159
160 StateType state = eStateInvalid;
161
162 if (!StopProcessIfNecessary(m_exe_ctx.GetProcessPtr(), state, result))
163 return;
164
165 // Determine whether we will disable ASLR or leave it in the default state
166 // (i.e. enabled if the platform supports it). First check if the process
167 // launch options explicitly turn on/off
168 // disabling ASLR. If so, use that setting;
169 // otherwise, use the 'settings target.disable-aslr' setting.
170 bool disable_aslr = false;
172 // The user specified an explicit setting on the process launch line.
173 // Use it.
174 disable_aslr = (m_options.disable_aslr == eLazyBoolYes);
175 } else {
176 // The user did not explicitly specify whether to disable ASLR. Fall
177 // back to the target.disable-aslr setting.
178 disable_aslr = target->GetDisableASLR();
179 }
180
181 if (!m_class_options.GetName().empty()) {
182 m_options.launch_info.SetProcessPluginName("ScriptedProcess");
183 ScriptedMetadataSP metadata_sp = std::make_shared<ScriptedMetadata>(
187 }
188
189 if (disable_aslr)
190 m_options.launch_info.GetFlags().Set(eLaunchFlagDisableASLR);
191 else
192 m_options.launch_info.GetFlags().Clear(eLaunchFlagDisableASLR);
193
194 if (target->GetInheritTCC())
195 m_options.launch_info.GetFlags().Set(eLaunchFlagInheritTCCFromParent);
196
197 if (target->GetDetachOnError())
198 m_options.launch_info.GetFlags().Set(eLaunchFlagDetachOnError);
199
200 if (target->GetDisableSTDIO())
201 m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
202
203 // Merge the launch info environment with the target environment.
204 Environment target_env = target->GetEnvironment();
205 m_options.launch_info.GetEnvironment().insert(target_env.begin(),
206 target_env.end());
207
208 llvm::StringRef target_settings_argv0 = target->GetArg0();
209
210 if (!target_settings_argv0.empty()) {
212 target_settings_argv0);
213 if (exe_module_sp)
215 exe_module_sp->GetPlatformFileSpec(), false);
216 else
218 } else {
219 if (exe_module_sp)
221 exe_module_sp->GetPlatformFileSpec(), true);
222 else
224 }
225
226 if (launch_args.GetArgumentCount() == 0) {
229 } else {
231 // Save the arguments for subsequent runs in the current target.
232 target->SetRunArguments(launch_args);
233 }
234
235 StreamString stream;
236 Status error = target->Launch(m_options.launch_info, &stream);
237
238 if (error.Success()) {
239 ProcessSP process_sp(target->GetProcessSP());
240 if (process_sp) {
241 // There is a race condition where this thread will return up the call
242 // stack to the main command handler and show an (lldb) prompt before
243 // HandlePrivateEvent (from PrivateStateThread) has a chance to call
244 // PushProcessIOHandler().
245 process_sp->SyncIOHandler(0, std::chrono::seconds(2));
246
247 // If we didn't have a local executable, then we wouldn't have had an
248 // executable module before launch.
249 if (!exe_module_sp)
250 exe_module_sp = target->GetExecutableModule();
251 if (!exe_module_sp) {
252 result.AppendWarning("Could not get executable module after launch.");
253 } else {
254
255 const char *archname =
256 exe_module_sp->GetArchitecture().GetArchitectureName();
258 "Process %" PRIu64 " launched: '%s' (%s)\n", process_sp->GetID(),
259 exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
260 }
262 // This message will refer to an event that happened after the process
263 // launched.
264 llvm::StringRef data = stream.GetString();
265 if (!data.empty())
266 result.AppendMessage(data);
267 result.SetDidChangeProcessState(true);
268 } else {
269 result.AppendError(
270 "no error returned from Target::Launch, and target has no process");
271 }
272 } else {
273 result.AppendError(error.AsCString());
274 }
275 }
276
280};
281
282#define LLDB_OPTIONS_process_attach
283#include "CommandOptions.inc"
284
285#pragma mark CommandObjectProcessAttach
287public:
290 interpreter, "process attach", "Attach to a process.",
291 "process attach <cmd-options>", 0, "attach"),
292 m_class_options("scripted process", true, 'C', 'k', 'v', 0) {
297 }
298
299 ~CommandObjectProcessAttach() override = default;
300
301 Options *GetOptions() override { return &m_all_options; }
302
303protected:
304 void DoExecute(Args &command, CommandReturnObject &result) override {
305 PlatformSP platform_sp(
306 GetDebugger().GetPlatformList().GetSelectedPlatform());
307
308 Target *target = GetDebugger().GetSelectedTarget().get();
309 // N.B. The attach should be synchronous. It doesn't help much to get the
310 // prompt back between initiating the attach and the target actually
311 // stopping. So even if the interpreter is set to be asynchronous, we wait
312 // for the stop ourselves here.
313
314 StateType state = eStateInvalid;
315 Process *process = m_exe_ctx.GetProcessPtr();
316
317 if (!StopProcessIfNecessary(process, state, result))
318 return;
319
320 if (target == nullptr) {
321 // If there isn't a current target create one.
322 TargetSP new_target_sp;
324
327 nullptr, // No platform options
328 new_target_sp);
329 target = new_target_sp.get();
330 if (target == nullptr || error.Fail()) {
331 result.AppendError(error.AsCString("Error creating target"));
332 return;
333 }
334 }
335
336 if (!m_class_options.GetName().empty()) {
337 m_options.attach_info.SetProcessPluginName("ScriptedProcess");
338 ScriptedMetadataSP metadata_sp = std::make_shared<ScriptedMetadata>(
341 }
342
343 // Record the old executable module, we want to issue a warning if the
344 // process of attaching changed the current executable (like somebody said
345 // "file foo" then attached to a PID whose executable was bar.)
346
347 ModuleSP old_exec_module_sp = target->GetExecutableModule();
348 ArchSpec old_arch_spec = target->GetArchitecture();
349
350 StreamString stream;
351 ProcessSP process_sp;
352 const auto error = target->Attach(m_options.attach_info, &stream);
353 if (error.Success()) {
354 process_sp = target->GetProcessSP();
355 if (process_sp) {
356 result.AppendMessage(stream.GetString());
358 result.SetDidChangeProcessState(true);
359 } else {
360 result.AppendError(
361 "no error returned from Target::Attach, and target has no process");
362 }
363 } else {
364 result.AppendErrorWithFormat("attach failed: %s\n", error.AsCString());
365 }
366
367 if (!result.Succeeded())
368 return;
369
370 // Okay, we're done. Last step is to warn if the executable module has
371 // changed:
372 ModuleSP new_exec_module_sp(target->GetExecutableModule());
373 if (!old_exec_module_sp) {
374 // We might not have a module if we attached to a raw pid...
375 if (new_exec_module_sp) {
377 "Executable binary set to \"%s\".\n",
378 new_exec_module_sp->GetFileSpec().GetPath().c_str());
379 }
380 } else if (!new_exec_module_sp) {
381 result.AppendWarningWithFormat("No executable binary.");
382 } else if (old_exec_module_sp->GetFileSpec() !=
383 new_exec_module_sp->GetFileSpec()) {
384
386 "Executable binary changed from \"%s\" to \"%s\".\n",
387 old_exec_module_sp->GetFileSpec().GetPath().c_str(),
388 new_exec_module_sp->GetFileSpec().GetPath().c_str());
389 }
390
391 if (!old_arch_spec.IsValid()) {
393 "Architecture set to: %s.\n",
394 target->GetArchitecture().GetTriple().getTriple().c_str());
395 } else if (!old_arch_spec.IsExactMatch(target->GetArchitecture())) {
397 "Architecture changed from %s to %s.\n",
398 old_arch_spec.GetTriple().getTriple().c_str(),
399 target->GetArchitecture().GetTriple().getTriple().c_str());
400 }
401
402 // This supports the use-case scenario of immediately continuing the
403 // process once attached.
405 // We have made a process but haven't told the interpreter about it yet,
406 // so CheckRequirements will fail for "process continue". Set the override
407 // here:
408 ExecutionContext exe_ctx(process_sp);
409 m_interpreter.HandleCommand("process continue", eLazyBoolNo, exe_ctx, result);
410 }
411 }
412
416};
417
418// CommandObjectProcessContinue
419
420#define LLDB_OPTIONS_process_continue
421#include "CommandOptions.inc"
422
423#pragma mark CommandObjectProcessContinue
424
426public:
429 interpreter, "process continue",
430 "Continue execution of all threads in the current process.",
431 "process continue",
432 eCommandRequiresProcess | eCommandTryTargetAPILock |
433 eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {}
434
435 ~CommandObjectProcessContinue() override = default;
436
437protected:
438 class CommandOptions : public Options {
439 public:
441 // Keep default values of all options in one place: OptionParsingStarting
442 // ()
443 OptionParsingStarting(nullptr);
444 }
445
446 ~CommandOptions() override = default;
447
448 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
449 ExecutionContext *exe_ctx) override {
451 const int short_option = m_getopt_table[option_idx].val;
452 switch (short_option) {
453 case 'i':
454 if (option_arg.getAsInteger(0, m_ignore))
455 error.SetErrorStringWithFormat(
456 "invalid value for ignore option: \"%s\", should be a number.",
457 option_arg.str().c_str());
458 break;
459 case 'b':
462 break;
463 default:
464 llvm_unreachable("Unimplemented option");
465 }
466 return error;
467 }
468
469 void OptionParsingStarting(ExecutionContext *execution_context) override {
470 m_ignore = 0;
472 m_any_bkpts_specified = false;
473 }
474
475 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
476 return llvm::ArrayRef(g_process_continue_options);
477 }
478
479 uint32_t m_ignore = 0;
482 };
483
484 void DoExecute(Args &command, CommandReturnObject &result) override {
485 Process *process = m_exe_ctx.GetProcessPtr();
486 bool synchronous_execution = m_interpreter.GetSynchronous();
487 StateType state = process->GetState();
488 if (state == eStateStopped) {
489 if (m_options.m_ignore > 0) {
490 ThreadSP sel_thread_sp(GetDefaultThread()->shared_from_this());
491 if (sel_thread_sp) {
492 StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo();
493 if (stop_info_sp &&
494 stop_info_sp->GetStopReason() == eStopReasonBreakpoint) {
495 lldb::break_id_t bp_site_id =
496 (lldb::break_id_t)stop_info_sp->GetValue();
497 BreakpointSiteSP bp_site_sp(
498 process->GetBreakpointSiteList().FindByID(bp_site_id));
499 if (bp_site_sp) {
500 const size_t num_owners = bp_site_sp->GetNumberOfConstituents();
501 for (size_t i = 0; i < num_owners; i++) {
502 Breakpoint &bp_ref =
503 bp_site_sp->GetConstituentAtIndex(i)->GetBreakpoint();
504 if (!bp_ref.IsInternal()) {
506 }
507 }
508 }
509 }
510 }
511 }
512
513 Target &target = GetTarget();
514 BreakpointIDList run_to_bkpt_ids;
515 // Don't pass an empty run_to_breakpoint list, as Verify will look for the
516 // default breakpoint.
519 m_options.m_run_to_bkpt_args, target, result, &run_to_bkpt_ids,
521 if (!result.Succeeded()) {
522 return;
523 }
524 result.Clear();
525 if (m_options.m_any_bkpts_specified && run_to_bkpt_ids.GetSize() == 0) {
526 result.AppendError("continue-to breakpoints did not specify any actual "
527 "breakpoints or locations");
528 return;
529 }
530
531 // First figure out which breakpoints & locations were specified by the
532 // user:
533 size_t num_run_to_bkpt_ids = run_to_bkpt_ids.GetSize();
534 std::vector<break_id_t> bkpts_disabled;
535 std::vector<BreakpointID> locs_disabled;
536 if (num_run_to_bkpt_ids != 0) {
537 // Go through the ID's specified, and separate the breakpoints from are
538 // the breakpoint.location specifications since the latter require
539 // special handling. We also figure out whether there's at least one
540 // specifier in the set that is enabled.
541 BreakpointList &bkpt_list = target.GetBreakpointList();
542 std::unordered_set<break_id_t> bkpts_seen;
543 std::unordered_set<break_id_t> bkpts_with_locs_seen;
544 BreakpointIDList with_locs;
545 bool any_enabled = false;
546
547 for (size_t idx = 0; idx < num_run_to_bkpt_ids; idx++) {
548 BreakpointID bkpt_id = run_to_bkpt_ids.GetBreakpointIDAtIndex(idx);
549 break_id_t bp_id = bkpt_id.GetBreakpointID();
550 break_id_t loc_id = bkpt_id.GetLocationID();
551 BreakpointSP bp_sp
552 = bkpt_list.FindBreakpointByID(bp_id);
553 // Note, VerifyBreakpointOrLocationIDs checks for existence, so we
554 // don't need to do it again here.
555 if (bp_sp->IsEnabled()) {
556 if (loc_id == LLDB_INVALID_BREAK_ID) {
557 // A breakpoint (without location) was specified. Make sure that
558 // at least one of the locations is enabled.
559 size_t num_locations = bp_sp->GetNumLocations();
560 for (size_t loc_idx = 0; loc_idx < num_locations; loc_idx++) {
562 = bp_sp->GetLocationAtIndex(loc_idx);
563 if (loc_sp->IsEnabled()) {
564 any_enabled = true;
565 break;
566 }
567 }
568 } else {
569 // A location was specified, check if it was enabled:
570 BreakpointLocationSP loc_sp = bp_sp->FindLocationByID(loc_id);
571 if (loc_sp->IsEnabled())
572 any_enabled = true;
573 }
574
575 // Then sort the bp & bp.loc entries for later use:
576 if (bkpt_id.GetLocationID() == LLDB_INVALID_BREAK_ID)
577 bkpts_seen.insert(bkpt_id.GetBreakpointID());
578 else {
579 bkpts_with_locs_seen.insert(bkpt_id.GetBreakpointID());
580 with_locs.AddBreakpointID(bkpt_id);
581 }
582 }
583 }
584 // Do all the error checking here so once we start disabling we don't
585 // have to back out half-way through.
586
587 // Make sure at least one of the specified breakpoints is enabled.
588 if (!any_enabled) {
589 result.AppendError("at least one of the continue-to breakpoints must "
590 "be enabled.");
591 return;
592 }
593
594 // Also, if you specify BOTH a breakpoint and one of it's locations,
595 // we flag that as an error, since it won't do what you expect, the
596 // breakpoint directive will mean "run to all locations", which is not
597 // what the location directive means...
598 for (break_id_t bp_id : bkpts_with_locs_seen) {
599 if (bkpts_seen.count(bp_id)) {
600 result.AppendErrorWithFormatv("can't specify both a breakpoint and "
601 "one of its locations: {0}", bp_id);
602 }
603 }
604
605 // Now go through the breakpoints in the target, disabling all the ones
606 // that the user didn't mention:
607 for (BreakpointSP bp_sp : bkpt_list.Breakpoints()) {
608 break_id_t bp_id = bp_sp->GetID();
609 // Handle the case where no locations were specified. Note we don't
610 // have to worry about the case where a breakpoint and one of its
611 // locations are both in the lists, we've already disallowed that.
612 if (!bkpts_with_locs_seen.count(bp_id)) {
613 if (!bkpts_seen.count(bp_id) && bp_sp->IsEnabled()) {
614 bkpts_disabled.push_back(bp_id);
615 bp_sp->SetEnabled(false);
616 }
617 continue;
618 }
619 // Next, handle the case where a location was specified:
620 // Run through all the locations of this breakpoint and disable
621 // the ones that aren't on our "with locations" BreakpointID list:
622 size_t num_locations = bp_sp->GetNumLocations();
623 BreakpointID tmp_id(bp_id, LLDB_INVALID_BREAK_ID);
624 for (size_t loc_idx = 0; loc_idx < num_locations; loc_idx++) {
625 BreakpointLocationSP loc_sp = bp_sp->GetLocationAtIndex(loc_idx);
626 tmp_id.SetBreakpointLocationID(loc_idx);
627 if (!with_locs.Contains(tmp_id) && loc_sp->IsEnabled()) {
628 locs_disabled.push_back(tmp_id);
629 loc_sp->SetEnabled(false);
630 }
631 }
632 }
633 }
634
635 { // Scope for thread list mutex:
636 std::lock_guard<std::recursive_mutex> guard(
637 process->GetThreadList().GetMutex());
638 const uint32_t num_threads = process->GetThreadList().GetSize();
639
640 // Set the actions that the threads should each take when resuming
641 for (uint32_t idx = 0; idx < num_threads; ++idx) {
642 const bool override_suspend = false;
643 process->GetThreadList().GetThreadAtIndex(idx)->SetResumeState(
644 eStateRunning, override_suspend);
645 }
646 }
647
648 const uint32_t iohandler_id = process->GetIOHandlerID();
649
650 StreamString stream;
652 // For now we can only do -b with synchronous:
653 bool old_sync = GetDebugger().GetAsyncExecution();
654
655 if (run_to_bkpt_ids.GetSize() != 0) {
657 synchronous_execution = true;
658 }
659 if (synchronous_execution)
660 error = process->ResumeSynchronous(&stream);
661 else
662 error = process->Resume();
663
664 if (run_to_bkpt_ids.GetSize() != 0) {
665 GetDebugger().SetAsyncExecution(old_sync);
666 }
667
668 // Now re-enable the breakpoints we disabled:
669 BreakpointList &bkpt_list = target.GetBreakpointList();
670 for (break_id_t bp_id : bkpts_disabled) {
671 BreakpointSP bp_sp = bkpt_list.FindBreakpointByID(bp_id);
672 if (bp_sp)
673 bp_sp->SetEnabled(true);
674 }
675 for (const BreakpointID &bkpt_id : locs_disabled) {
676 BreakpointSP bp_sp
677 = bkpt_list.FindBreakpointByID(bkpt_id.GetBreakpointID());
678 if (bp_sp) {
680 = bp_sp->FindLocationByID(bkpt_id.GetLocationID());
681 if (loc_sp)
682 loc_sp->SetEnabled(true);
683 }
684 }
685
686 if (error.Success()) {
687 // There is a race condition where this thread will return up the call
688 // stack to the main command handler and show an (lldb) prompt before
689 // HandlePrivateEvent (from PrivateStateThread) has a chance to call
690 // PushProcessIOHandler().
691 process->SyncIOHandler(iohandler_id, std::chrono::seconds(2));
692
693 result.AppendMessageWithFormat("Process %" PRIu64 " resuming\n",
694 process->GetID());
695 if (synchronous_execution) {
696 // If any state changed events had anything to say, add that to the
697 // result
698 result.AppendMessage(stream.GetString());
699
700 result.SetDidChangeProcessState(true);
702 } else {
704 }
705 } else {
706 result.AppendErrorWithFormat("Failed to resume process: %s.\n",
707 error.AsCString());
708 }
709 } else {
711 "Process cannot be continued from its current state (%s).\n",
712 StateAsCString(state));
713 }
714 }
715
716 Options *GetOptions() override { return &m_options; }
717
719};
720
721// CommandObjectProcessDetach
722#define LLDB_OPTIONS_process_detach
723#include "CommandOptions.inc"
724
725#pragma mark CommandObjectProcessDetach
726
728public:
729 class CommandOptions : public Options {
730 public:
732
733 ~CommandOptions() override = default;
734
735 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
736 ExecutionContext *execution_context) override {
738 const int short_option = m_getopt_table[option_idx].val;
739
740 switch (short_option) {
741 case 's':
742 bool tmp_result;
743 bool success;
744 tmp_result = OptionArgParser::ToBoolean(option_arg, false, &success);
745 if (!success)
746 error.SetErrorStringWithFormat("invalid boolean option: \"%s\"",
747 option_arg.str().c_str());
748 else {
749 if (tmp_result)
751 else
753 }
754 break;
755 default:
756 llvm_unreachable("Unimplemented option");
757 }
758 return error;
759 }
760
761 void OptionParsingStarting(ExecutionContext *execution_context) override {
763 }
764
765 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
766 return llvm::ArrayRef(g_process_detach_options);
767 }
768
769 // Instance variables to hold the values for command options.
771 };
772
774 : CommandObjectParsed(interpreter, "process detach",
775 "Detach from the current target process.",
776 "process detach",
777 eCommandRequiresProcess | eCommandTryTargetAPILock |
778 eCommandProcessMustBeLaunched) {}
779
780 ~CommandObjectProcessDetach() override = default;
781
782 Options *GetOptions() override { return &m_options; }
783
784protected:
785 void DoExecute(Args &command, CommandReturnObject &result) override {
786 Process *process = m_exe_ctx.GetProcessPtr();
787 // FIXME: This will be a Command Option:
788 bool keep_stopped;
790 // Check the process default:
791 keep_stopped = process->GetDetachKeepsStopped();
793 keep_stopped = true;
794 else
795 keep_stopped = false;
796
797 Status error(process->Detach(keep_stopped));
798 if (error.Success()) {
800 } else {
801 result.AppendErrorWithFormat("Detach failed: %s\n", error.AsCString());
802 }
803 }
804
806};
807
808// CommandObjectProcessConnect
809#define LLDB_OPTIONS_process_connect
810#include "CommandOptions.inc"
811
812#pragma mark CommandObjectProcessConnect
813
815public:
816 class CommandOptions : public Options {
817 public:
819 // Keep default values of all options in one place: OptionParsingStarting
820 // ()
821 OptionParsingStarting(nullptr);
822 }
823
824 ~CommandOptions() override = default;
825
826 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
827 ExecutionContext *execution_context) override {
829 const int short_option = m_getopt_table[option_idx].val;
830
831 switch (short_option) {
832 case 'p':
833 plugin_name.assign(std::string(option_arg));
834 break;
835
836 default:
837 llvm_unreachable("Unimplemented option");
838 }
839 return error;
840 }
841
842 void OptionParsingStarting(ExecutionContext *execution_context) override {
843 plugin_name.clear();
844 }
845
846 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
847 return llvm::ArrayRef(g_process_connect_options);
848 }
849
850 // Instance variables to hold the values for command options.
851
852 std::string plugin_name;
853 };
854
856 : CommandObjectParsed(interpreter, "process connect",
857 "Connect to a remote debug service.",
858 "process connect <remote-url>", 0) {
860 }
861
862 ~CommandObjectProcessConnect() override = default;
863
864 Options *GetOptions() override { return &m_options; }
865
866protected:
867 void DoExecute(Args &command, CommandReturnObject &result) override {
868 if (command.GetArgumentCount() != 1) {
870 "'%s' takes exactly one argument:\nUsage: %s\n", m_cmd_name.c_str(),
871 m_cmd_syntax.c_str());
872 return;
873 }
874
875 Process *process = m_exe_ctx.GetProcessPtr();
876 if (process && process->IsAlive()) {
878 "Process %" PRIu64
879 " is currently being debugged, kill the process before connecting.\n",
880 process->GetID());
881 return;
882 }
883
884 const char *plugin_name = nullptr;
885 if (!m_options.plugin_name.empty())
886 plugin_name = m_options.plugin_name.c_str();
887
889 Debugger &debugger = GetDebugger();
890 PlatformSP platform_sp = m_interpreter.GetPlatform(true);
891 ProcessSP process_sp =
892 debugger.GetAsyncExecution()
893 ? platform_sp->ConnectProcess(
894 command.GetArgumentAtIndex(0), plugin_name, debugger,
895 debugger.GetSelectedTarget().get(), error)
896 : platform_sp->ConnectProcessSynchronous(
897 command.GetArgumentAtIndex(0), plugin_name, debugger,
898 result.GetOutputStream(), debugger.GetSelectedTarget().get(),
899 error);
900 if (error.Fail() || process_sp == nullptr) {
901 result.AppendError(error.AsCString("Error connecting to the process"));
902 }
903 }
904
906};
907
908// CommandObjectProcessPlugin
909#pragma mark CommandObjectProcessPlugin
910
912public:
915 interpreter, "process plugin",
916 "Send a custom command to the current target process plug-in.",
917 "process plugin <args>", 0) {}
918
919 ~CommandObjectProcessPlugin() override = default;
920
923 if (process)
924 return process->GetPluginCommandObject();
925 return nullptr;
926 }
927};
928
929// CommandObjectProcessLoad
930#define LLDB_OPTIONS_process_load
931#include "CommandOptions.inc"
932
933#pragma mark CommandObjectProcessLoad
934
936public:
937 class CommandOptions : public Options {
938 public:
940 // Keep default values of all options in one place: OptionParsingStarting
941 // ()
942 OptionParsingStarting(nullptr);
943 }
944
945 ~CommandOptions() override = default;
946
947 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
948 ExecutionContext *execution_context) override {
950 const int short_option = m_getopt_table[option_idx].val;
951 ArchSpec arch =
952 execution_context->GetProcessPtr()->GetSystemArchitecture();
953 switch (short_option) {
954 case 'i':
955 do_install = true;
956 if (!option_arg.empty())
957 install_path.SetFile(option_arg, arch.GetTriple());
958 break;
959 default:
960 llvm_unreachable("Unimplemented option");
961 }
962 return error;
963 }
964
965 void OptionParsingStarting(ExecutionContext *execution_context) override {
966 do_install = false;
968 }
969
970 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
971 return llvm::ArrayRef(g_process_load_options);
972 }
973
974 // Instance variables to hold the values for command options.
977 };
978
980 : CommandObjectParsed(interpreter, "process load",
981 "Load a shared library into the current process.",
982 "process load <filename> [<filename> ...]",
983 eCommandRequiresProcess | eCommandTryTargetAPILock |
984 eCommandProcessMustBeLaunched |
985 eCommandProcessMustBePaused) {
987 }
988
989 ~CommandObjectProcessLoad() override = default;
990
991 void
993 OptionElementVector &opt_element_vector) override {
995 return;
996 CommandObject::HandleArgumentCompletion(request, opt_element_vector);
997 }
998
999 Options *GetOptions() override { return &m_options; }
1000
1001protected:
1002 void DoExecute(Args &command, CommandReturnObject &result) override {
1003 Process *process = m_exe_ctx.GetProcessPtr();
1004
1005 for (auto &entry : command.entries()) {
1006 Status error;
1007 PlatformSP platform = process->GetTarget().GetPlatform();
1008 llvm::StringRef image_path = entry.ref();
1009 uint32_t image_token = LLDB_INVALID_IMAGE_TOKEN;
1010
1011 if (!m_options.do_install) {
1012 FileSpec image_spec(image_path);
1013 platform->ResolveRemotePath(image_spec, image_spec);
1014 image_token =
1015 platform->LoadImage(process, FileSpec(), image_spec, error);
1016 } else if (m_options.install_path) {
1017 FileSpec image_spec(image_path);
1018 FileSystem::Instance().Resolve(image_spec);
1019 platform->ResolveRemotePath(m_options.install_path,
1021 image_token = platform->LoadImage(process, image_spec,
1023 } else {
1024 FileSpec image_spec(image_path);
1025 FileSystem::Instance().Resolve(image_spec);
1026 image_token =
1027 platform->LoadImage(process, image_spec, FileSpec(), error);
1028 }
1029
1030 if (image_token != LLDB_INVALID_IMAGE_TOKEN) {
1032 "Loading \"%s\"...ok\nImage %u loaded.\n", image_path.str().c_str(),
1033 image_token);
1035 } else {
1036 result.AppendErrorWithFormat("failed to load '%s': %s",
1037 image_path.str().c_str(),
1038 error.AsCString());
1039 }
1040 }
1041 }
1042
1044};
1045
1046// CommandObjectProcessUnload
1047#pragma mark CommandObjectProcessUnload
1048
1050public:
1053 interpreter, "process unload",
1054 "Unload a shared library from the current process using the index "
1055 "returned by a previous call to \"process load\".",
1056 "process unload <index>",
1057 eCommandRequiresProcess | eCommandTryTargetAPILock |
1058 eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {
1060 }
1061
1062 ~CommandObjectProcessUnload() override = default;
1063
1064 void
1066 OptionElementVector &opt_element_vector) override {
1067
1068 if (request.GetCursorIndex() || !m_exe_ctx.HasProcessScope())
1069 return;
1070
1071 Process *process = m_exe_ctx.GetProcessPtr();
1072
1073 const std::vector<lldb::addr_t> &tokens = process->GetImageTokens();
1074 const size_t token_num = tokens.size();
1075 for (size_t i = 0; i < token_num; ++i) {
1076 if (tokens[i] == LLDB_INVALID_IMAGE_TOKEN)
1077 continue;
1078 request.TryCompleteCurrentArg(std::to_string(i));
1079 }
1080 }
1081
1082protected:
1083 void DoExecute(Args &command, CommandReturnObject &result) override {
1084 Process *process = m_exe_ctx.GetProcessPtr();
1085
1086 for (auto &entry : command.entries()) {
1087 uint32_t image_token;
1088 if (entry.ref().getAsInteger(0, image_token)) {
1089 result.AppendErrorWithFormat("invalid image index argument '%s'",
1090 entry.ref().str().c_str());
1091 break;
1092 } else {
1093 Status error(process->GetTarget().GetPlatform()->UnloadImage(
1094 process, image_token));
1095 if (error.Success()) {
1097 "Unloading shared library with index %u...ok\n", image_token);
1099 } else {
1100 result.AppendErrorWithFormat("failed to unload image: %s",
1101 error.AsCString());
1102 break;
1103 }
1104 }
1105 }
1106 }
1107};
1108
1109// CommandObjectProcessSignal
1110#pragma mark CommandObjectProcessSignal
1111
1113public:
1116 interpreter, "process signal",
1117 "Send a UNIX signal to the current target process.", nullptr,
1118 eCommandRequiresProcess | eCommandTryTargetAPILock) {
1120 }
1121
1122 ~CommandObjectProcessSignal() override = default;
1123
1124 void
1126 OptionElementVector &opt_element_vector) override {
1127 if (!m_exe_ctx.HasProcessScope() || request.GetCursorIndex() != 0)
1128 return;
1129
1131 int signo = signals->GetFirstSignalNumber();
1132 while (signo != LLDB_INVALID_SIGNAL_NUMBER) {
1133 request.TryCompleteCurrentArg(signals->GetSignalAsStringRef(signo));
1134 signo = signals->GetNextSignalNumber(signo);
1135 }
1136 }
1137
1138protected:
1139 void DoExecute(Args &command, CommandReturnObject &result) override {
1140 Process *process = m_exe_ctx.GetProcessPtr();
1141
1142 if (command.GetArgumentCount() == 1) {
1143 int signo = LLDB_INVALID_SIGNAL_NUMBER;
1144
1145 const char *signal_name = command.GetArgumentAtIndex(0);
1146 if (::isxdigit(signal_name[0])) {
1147 if (!llvm::to_integer(signal_name, signo))
1149 } else
1150 signo = process->GetUnixSignals()->GetSignalNumberFromName(signal_name);
1151
1152 if (signo == LLDB_INVALID_SIGNAL_NUMBER) {
1153 result.AppendErrorWithFormat("Invalid signal argument '%s'.\n",
1154 command.GetArgumentAtIndex(0));
1155 } else {
1156 Status error(process->Signal(signo));
1157 if (error.Success()) {
1159 } else {
1160 result.AppendErrorWithFormat("Failed to send signal %i: %s\n", signo,
1161 error.AsCString());
1162 }
1163 }
1164 } else {
1165 result.AppendErrorWithFormat(
1166 "'%s' takes exactly one signal number argument:\nUsage: %s\n",
1167 m_cmd_name.c_str(), m_cmd_syntax.c_str());
1168 }
1169 }
1170};
1171
1172// CommandObjectProcessInterrupt
1173#pragma mark CommandObjectProcessInterrupt
1174
1176public:
1178 : CommandObjectParsed(interpreter, "process interrupt",
1179 "Interrupt the current target process.",
1180 "process interrupt",
1181 eCommandRequiresProcess | eCommandTryTargetAPILock |
1182 eCommandProcessMustBeLaunched) {}
1183
1185
1186protected:
1187 void DoExecute(Args &command, CommandReturnObject &result) override {
1188 Process *process = m_exe_ctx.GetProcessPtr();
1189 if (process == nullptr) {
1190 result.AppendError("no process to halt");
1191 return;
1192 }
1193
1194 bool clear_thread_plans = true;
1195 Status error(process->Halt(clear_thread_plans));
1196 if (error.Success()) {
1198 } else {
1199 result.AppendErrorWithFormat("Failed to halt process: %s\n",
1200 error.AsCString());
1201 }
1202 }
1203};
1204
1205// CommandObjectProcessKill
1206#pragma mark CommandObjectProcessKill
1207
1209public:
1211 : CommandObjectParsed(interpreter, "process kill",
1212 "Terminate the current target process.",
1213 "process kill",
1214 eCommandRequiresProcess | eCommandTryTargetAPILock |
1215 eCommandProcessMustBeLaunched) {}
1216
1217 ~CommandObjectProcessKill() override = default;
1218
1219protected:
1220 void DoExecute(Args &command, CommandReturnObject &result) override {
1221 Process *process = m_exe_ctx.GetProcessPtr();
1222 if (process == nullptr) {
1223 result.AppendError("no process to kill");
1224 return;
1225 }
1226
1227 Status error(process->Destroy(true));
1228 if (error.Success()) {
1230 } else {
1231 result.AppendErrorWithFormat("Failed to kill process: %s\n",
1232 error.AsCString());
1233 }
1234 }
1235};
1236
1237#define LLDB_OPTIONS_process_save_core
1238#include "CommandOptions.inc"
1239
1241public:
1244 interpreter, "process save-core",
1245 "Save the current process as a core file using an "
1246 "appropriate file type.",
1247 "process save-core [-s corefile-style -p plugin-name] FILE",
1248 eCommandRequiresProcess | eCommandTryTargetAPILock |
1249 eCommandProcessMustBeLaunched) {
1251 }
1252
1253 ~CommandObjectProcessSaveCore() override = default;
1254
1255 Options *GetOptions() override { return &m_options; }
1256
1257 class CommandOptions : public Options {
1258 public:
1259 CommandOptions() = default;
1260
1261 ~CommandOptions() override = default;
1262
1263 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1264 return llvm::ArrayRef(g_process_save_core_options);
1265 }
1266
1267 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1268 ExecutionContext *execution_context) override {
1269 const int short_option = m_getopt_table[option_idx].val;
1270 Status error;
1271
1272 switch (short_option) {
1273 case 'p':
1274 error = m_core_dump_options.SetPluginName(option_arg.data());
1275 break;
1276 case 's':
1279 option_arg, GetDefinitions()[option_idx].enum_values,
1281 break;
1282 default:
1283 llvm_unreachable("Unimplemented option");
1284 }
1285
1286 return {};
1287 }
1288
1289 void OptionParsingStarting(ExecutionContext *execution_context) override {
1291 }
1292
1293 // Instance variables to hold the values for command options.
1295 };
1296
1297protected:
1298 void DoExecute(Args &command, CommandReturnObject &result) override {
1299 ProcessSP process_sp = m_exe_ctx.GetProcessSP();
1300 if (process_sp) {
1301 if (command.GetArgumentCount() == 1) {
1302 FileSpec output_file(command.GetArgumentAtIndex(0));
1303 FileSystem::Instance().Resolve(output_file);
1304 auto &core_dump_options = m_options.m_core_dump_options;
1305 core_dump_options.SetOutputFile(output_file);
1306 Status error = PluginManager::SaveCore(process_sp, core_dump_options);
1307 if (error.Success()) {
1308 if (core_dump_options.GetStyle() ==
1309 SaveCoreStyle::eSaveCoreDirtyOnly ||
1310 core_dump_options.GetStyle() ==
1311 SaveCoreStyle::eSaveCoreStackOnly) {
1313 "\nModified-memory or stack-memory only corefile "
1314 "created. This corefile may \n"
1315 "not show library/framework/app binaries "
1316 "on a different system, or when \n"
1317 "those binaries have "
1318 "been updated/modified. Copies are not included\n"
1319 "in this corefile. Use --style full to include all "
1320 "process memory.\n");
1321 }
1323 } else {
1324 result.AppendErrorWithFormat(
1325 "Failed to save core file for process: %s\n", error.AsCString());
1326 }
1327 } else {
1328 result.AppendErrorWithFormat("'%s' takes one arguments:\nUsage: %s\n",
1329 m_cmd_name.c_str(), m_cmd_syntax.c_str());
1330 }
1331 } else {
1332 result.AppendError("invalid process");
1333 }
1334 }
1335
1337};
1338
1339// CommandObjectProcessStatus
1340#pragma mark CommandObjectProcessStatus
1341#define LLDB_OPTIONS_process_status
1342#include "CommandOptions.inc"
1343
1345public:
1348 interpreter, "process status",
1349 "Show status and stop location for the current target process.",
1350 "process status",
1351 eCommandRequiresProcess | eCommandTryTargetAPILock) {}
1352
1353 ~CommandObjectProcessStatus() override = default;
1354
1355 Options *GetOptions() override { return &m_options; }
1356
1357 class CommandOptions : public Options {
1358 public:
1359 CommandOptions() = default;
1360
1361 ~CommandOptions() override = default;
1362
1363 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1364 ExecutionContext *execution_context) override {
1365 const int short_option = m_getopt_table[option_idx].val;
1366
1367 switch (short_option) {
1368 case 'v':
1369 m_verbose = true;
1370 break;
1371 default:
1372 llvm_unreachable("Unimplemented option");
1373 }
1374
1375 return {};
1376 }
1377
1378 void OptionParsingStarting(ExecutionContext *execution_context) override {
1379 m_verbose = false;
1380 }
1381
1382 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1383 return llvm::ArrayRef(g_process_status_options);
1384 }
1385
1386 // Instance variables to hold the values for command options.
1387 bool m_verbose = false;
1388 };
1389
1390protected:
1391 void DoExecute(Args &command, CommandReturnObject &result) override {
1392 Stream &strm = result.GetOutputStream();
1394
1395 // No need to check "process" for validity as eCommandRequiresProcess
1396 // ensures it is valid
1397 Process *process = m_exe_ctx.GetProcessPtr();
1398 const bool only_threads_with_stop_reason = true;
1399 const uint32_t start_frame = 0;
1400 const uint32_t num_frames = 1;
1401 const uint32_t num_frames_with_source = 1;
1402 const bool stop_format = true;
1403 process->GetStatus(strm);
1404 process->GetThreadStatus(strm, only_threads_with_stop_reason, start_frame,
1405 num_frames, num_frames_with_source, stop_format);
1406
1407 if (m_options.m_verbose) {
1408 addr_t code_mask = process->GetCodeAddressMask();
1409 addr_t data_mask = process->GetDataAddressMask();
1410 if (code_mask != LLDB_INVALID_ADDRESS_MASK) {
1411 int bits = std::bitset<64>(~code_mask).count();
1413 "Addressable code address mask: 0x%" PRIx64 "\n", code_mask);
1415 "Addressable data address mask: 0x%" PRIx64 "\n", data_mask);
1417 "Number of bits used in addressing (code): %d\n", bits);
1418 }
1419
1420 PlatformSP platform_sp = process->GetTarget().GetPlatform();
1421 if (!platform_sp) {
1422 result.AppendError("Couldn'retrieve the target's platform");
1423 return;
1424 }
1425
1426 auto expected_crash_info =
1427 platform_sp->FetchExtendedCrashInformation(*process);
1428
1429 if (!expected_crash_info) {
1430 result.AppendError(llvm::toString(expected_crash_info.takeError()));
1431 return;
1432 }
1433
1434 StructuredData::DictionarySP crash_info_sp = *expected_crash_info;
1435
1436 if (crash_info_sp) {
1437 strm.EOL();
1438 strm.PutCString("Extended Crash Information:\n");
1439 crash_info_sp->GetDescription(strm);
1440 }
1441 }
1442 }
1443
1444private:
1446};
1447
1448// CommandObjectProcessHandle
1449#define LLDB_OPTIONS_process_handle
1450#include "CommandOptions.inc"
1451
1452#pragma mark CommandObjectProcessHandle
1453
1455public:
1456 class CommandOptions : public Options {
1457 public:
1459
1460 ~CommandOptions() override = default;
1461
1462 Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
1463 ExecutionContext *execution_context) override {
1464 Status error;
1465 const int short_option = m_getopt_table[option_idx].val;
1466
1467 switch (short_option) {
1468 case 'c':
1469 do_clear = true;
1470 break;
1471 case 'd':
1472 dummy = true;
1473 break;
1474 case 's':
1475 stop = std::string(option_arg);
1476 break;
1477 case 'n':
1478 notify = std::string(option_arg);
1479 break;
1480 case 'p':
1481 pass = std::string(option_arg);
1482 break;
1483 case 't':
1484 only_target_values = true;
1485 break;
1486 default:
1487 llvm_unreachable("Unimplemented option");
1488 }
1489 return error;
1490 }
1491
1492 void OptionParsingStarting(ExecutionContext *execution_context) override {
1493 stop.clear();
1494 notify.clear();
1495 pass.clear();
1496 only_target_values = false;
1497 do_clear = false;
1498 dummy = false;
1499 }
1500
1501 llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
1502 return llvm::ArrayRef(g_process_handle_options);
1503 }
1504
1505 // Instance variables to hold the values for command options.
1506
1507 std::string stop;
1508 std::string notify;
1509 std::string pass;
1511 bool do_clear = false;
1512 bool dummy = false;
1513 };
1514
1516 : CommandObjectParsed(interpreter, "process handle",
1517 "Manage LLDB handling of OS signals for the "
1518 "current target process. Defaults to showing "
1519 "current policy.",
1520 nullptr) {
1521 SetHelpLong("\nIf no signals are specified but one or more actions are, "
1522 "and there is a live process, update them all. If no action "
1523 "is specified, list the current values.\n"
1524 "If you specify actions with no target (e.g. in an init file) "
1525 "or in a target with no process "
1526 "the values will get copied into subsequent targets, but "
1527 "lldb won't be able to spell-check the options since it can't "
1528 "know which signal set will later be in force."
1529 "\nYou can see the signal modifications held by the target"
1530 "by passing the -t option."
1531 "\nYou can also clear the target modification for a signal"
1532 "by passing the -c option");
1534 }
1535
1536 ~CommandObjectProcessHandle() override = default;
1537
1538 Options *GetOptions() override { return &m_options; }
1539
1541 str.Printf("NAME PASS STOP NOTIFY\n");
1542 str.Printf("=========== ===== ===== ======\n");
1543 }
1544
1545 void PrintSignal(Stream &str, int32_t signo, llvm::StringRef sig_name,
1546 const UnixSignalsSP &signals_sp) {
1547 bool stop;
1548 bool suppress;
1549 bool notify;
1550
1551 str.Format("{0, -11} ", sig_name);
1552 if (signals_sp->GetSignalInfo(signo, suppress, stop, notify)) {
1553 bool pass = !suppress;
1554 str.Printf("%s %s %s", (pass ? "true " : "false"),
1555 (stop ? "true " : "false"), (notify ? "true " : "false"));
1556 }
1557 str.Printf("\n");
1558 }
1559
1560 void PrintSignalInformation(Stream &str, Args &signal_args,
1561 int num_valid_signals,
1562 const UnixSignalsSP &signals_sp) {
1563 PrintSignalHeader(str);
1564
1565 if (num_valid_signals > 0) {
1566 size_t num_args = signal_args.GetArgumentCount();
1567 for (size_t i = 0; i < num_args; ++i) {
1568 int32_t signo = signals_sp->GetSignalNumberFromName(
1569 signal_args.GetArgumentAtIndex(i));
1570 if (signo != LLDB_INVALID_SIGNAL_NUMBER)
1571 PrintSignal(str, signo, signal_args.GetArgumentAtIndex(i),
1572 signals_sp);
1573 }
1574 } else // Print info for ALL signals
1575 {
1576 int32_t signo = signals_sp->GetFirstSignalNumber();
1577 while (signo != LLDB_INVALID_SIGNAL_NUMBER) {
1578 PrintSignal(str, signo, signals_sp->GetSignalAsStringRef(signo),
1579 signals_sp);
1580 signo = signals_sp->GetNextSignalNumber(signo);
1581 }
1582 }
1583 }
1584
1585protected:
1586 void DoExecute(Args &signal_args, CommandReturnObject &result) override {
1587 Target &target = GetTarget();
1588
1589 // Any signals that are being set should be added to the Target's
1590 // DummySignals so they will get applied on rerun, etc.
1591 // If we have a process, however, we can do a more accurate job of vetting
1592 // the user's options.
1593 ProcessSP process_sp = target.GetProcessSP();
1594
1595 std::optional<bool> stop_action = {};
1596 std::optional<bool> pass_action = {};
1597 std::optional<bool> notify_action = {};
1598
1599 if (!m_options.stop.empty()) {
1600 bool success = false;
1601 bool value = OptionArgParser::ToBoolean(m_options.stop, false, &success);
1602 if (!success) {
1603 result.AppendError(
1604 "Invalid argument for command option --stop; must be "
1605 "true or false.\n");
1606 return;
1607 }
1608
1609 stop_action = value;
1610 }
1611
1612 if (!m_options.pass.empty()) {
1613 bool success = false;
1614 bool value = OptionArgParser::ToBoolean(m_options.pass, false, &success);
1615 if (!success) {
1616 result.AppendError(
1617 "Invalid argument for command option --pass; must be "
1618 "true or false.\n");
1619 return;
1620 }
1621 pass_action = value;
1622 }
1623
1624 if (!m_options.notify.empty()) {
1625 bool success = false;
1626 bool value =
1628 if (!success) {
1629 result.AppendError("Invalid argument for command option --notify; must "
1630 "be true or false.\n");
1631 return;
1632 }
1633 notify_action = value;
1634 }
1635
1636 if (!m_options.notify.empty() && !notify_action.has_value()) {
1637 }
1638
1639 bool no_actions = (!stop_action.has_value() && !pass_action.has_value() &&
1640 !notify_action.has_value());
1641 if (m_options.only_target_values && !no_actions) {
1642 result.AppendError("-t is for reporting, not setting, target values.");
1643 return;
1644 }
1645
1646 size_t num_args = signal_args.GetArgumentCount();
1647 UnixSignalsSP signals_sp;
1648 if (process_sp)
1649 signals_sp = process_sp->GetUnixSignals();
1650
1651 int num_signals_set = 0;
1652
1653 // If we were just asked to print the target values, do that here and
1654 // return:
1656 target.PrintDummySignals(result.GetOutputStream(), signal_args);
1658 return;
1659 }
1660
1661 // This handles clearing values:
1662 if (m_options.do_clear) {
1663 target.ClearDummySignals(signal_args);
1664 if (m_options.dummy)
1665 GetDummyTarget().ClearDummySignals(signal_args);
1667 return;
1668 }
1669
1670 // This rest handles setting values:
1671 if (num_args > 0) {
1672 for (const auto &arg : signal_args) {
1673 // Do the process first. If we have a process we can catch
1674 // invalid signal names, which we do here.
1675 if (signals_sp) {
1676 int32_t signo = signals_sp->GetSignalNumberFromName(arg.c_str());
1677 if (signo != LLDB_INVALID_SIGNAL_NUMBER) {
1678 if (stop_action.has_value())
1679 signals_sp->SetShouldStop(signo, *stop_action);
1680 if (pass_action.has_value()) {
1681 bool suppress = !*pass_action;
1682 signals_sp->SetShouldSuppress(signo, suppress);
1683 }
1684 if (notify_action.has_value())
1685 signals_sp->SetShouldNotify(signo, *notify_action);
1686 ++num_signals_set;
1687 } else {
1688 result.AppendErrorWithFormat("Invalid signal name '%s'\n",
1689 arg.c_str());
1690 continue;
1691 }
1692 } else {
1693 // If there's no process we can't check, so we just set them all.
1694 // But since the map signal name -> signal number across all platforms
1695 // is not 1-1, we can't sensibly set signal actions by number before
1696 // we have a process. Check that here:
1697 int32_t signo;
1698 if (llvm::to_integer(arg.c_str(), signo)) {
1699 result.AppendErrorWithFormat("Can't set signal handling by signal "
1700 "number with no process");
1701 return;
1702 }
1703 num_signals_set = num_args;
1704 }
1705 auto set_lazy_bool = [](std::optional<bool> action) -> LazyBool {
1706 if (!action.has_value())
1707 return eLazyBoolCalculate;
1708 return (*action) ? eLazyBoolYes : eLazyBoolNo;
1709 };
1710
1711 // If there were no actions, we're just listing, don't add the dummy:
1712 if (!no_actions)
1713 target.AddDummySignal(arg.ref(), set_lazy_bool(pass_action),
1714 set_lazy_bool(notify_action),
1715 set_lazy_bool(stop_action));
1716 }
1717 } else {
1718 // No signal specified, if any command options were specified, update ALL
1719 // signals. But we can't do this without a process since we don't know
1720 // all the possible signals that might be valid for this target.
1721 if ((notify_action.has_value() || stop_action.has_value() ||
1722 pass_action.has_value()) &&
1723 process_sp) {
1725 "Do you really want to update all the signals?", false)) {
1726 int32_t signo = signals_sp->GetFirstSignalNumber();
1727 while (signo != LLDB_INVALID_SIGNAL_NUMBER) {
1728 if (notify_action.has_value())
1729 signals_sp->SetShouldNotify(signo, *notify_action);
1730 if (stop_action.has_value())
1731 signals_sp->SetShouldStop(signo, *stop_action);
1732 if (pass_action.has_value()) {
1733 bool suppress = !*pass_action;
1734 signals_sp->SetShouldSuppress(signo, suppress);
1735 }
1736 signo = signals_sp->GetNextSignalNumber(signo);
1737 }
1738 }
1739 }
1740 }
1741
1742 if (signals_sp)
1743 PrintSignalInformation(result.GetOutputStream(), signal_args,
1744 num_signals_set, signals_sp);
1745 else
1746 target.PrintDummySignals(result.GetOutputStream(),
1747 signal_args);
1748
1749 if (num_signals_set > 0)
1751 else
1753 }
1754
1756};
1757
1758// Next are the subcommands of CommandObjectMultiwordProcessTrace
1759
1760// CommandObjectProcessTraceStart
1762public:
1765 /*live_debug_session_only*/ true, interpreter,
1766 "process trace start",
1767 "Start tracing this process with the corresponding trace "
1768 "plug-in.",
1769 "process trace start [<trace-options>]") {}
1770
1771protected:
1774 }
1775};
1776
1777// CommandObjectProcessTraceStop
1779public:
1781 : CommandObjectParsed(interpreter, "process trace stop",
1782 "Stop tracing this process. This does not affect "
1783 "traces started with the "
1784 "\"thread trace start\" command.",
1785 "process trace stop",
1786 eCommandRequiresProcess | eCommandTryTargetAPILock |
1787 eCommandProcessMustBeLaunched |
1788 eCommandProcessMustBePaused |
1789 eCommandProcessMustBeTraced) {}
1790
1792
1793 void DoExecute(Args &command, CommandReturnObject &result) override {
1794 ProcessSP process_sp = m_exe_ctx.GetProcessSP();
1795
1796 TraceSP trace_sp = process_sp->GetTarget().GetTrace();
1797
1798 if (llvm::Error err = trace_sp->Stop())
1799 result.AppendError(toString(std::move(err)));
1800 else
1802 }
1803};
1804
1805// CommandObjectMultiwordProcessTrace
1807public:
1810 interpreter, "trace", "Commands for tracing the current process.",
1811 "process trace <subcommand> [<subcommand objects>]") {
1813 interpreter)));
1815 new CommandObjectProcessTraceStop(interpreter)));
1816 }
1817
1819};
1820
1821// CommandObjectMultiwordProcess
1822
1824 CommandInterpreter &interpreter)
1826 interpreter, "process",
1827 "Commands for interacting with processes on the current platform.",
1828 "process <subcommand> [<subcommand-options>]") {
1829 LoadSubCommand("attach",
1831 LoadSubCommand("launch",
1834 interpreter)));
1835 LoadSubCommand("connect",
1837 LoadSubCommand("detach",
1839 LoadSubCommand("load",
1840 CommandObjectSP(new CommandObjectProcessLoad(interpreter)));
1841 LoadSubCommand("unload",
1843 LoadSubCommand("signal",
1845 LoadSubCommand("handle",
1847 LoadSubCommand("status",
1850 interpreter)));
1851 LoadSubCommand("kill",
1852 CommandObjectSP(new CommandObjectProcessKill(interpreter)));
1853 LoadSubCommand("plugin",
1856 interpreter)));
1858 "trace",
1860}
1861
static llvm::raw_ostream & error(Stream &strm)
~CommandObjectMultiwordProcessTrace() override=default
CommandObjectMultiwordProcessTrace(CommandInterpreter &interpreter)
CommandOptionsProcessAttach m_options
~CommandObjectProcessAttach() override=default
OptionGroupPythonClassWithDict m_class_options
CommandObjectProcessAttach(CommandInterpreter &interpreter)
void DoExecute(Args &command, CommandReturnObject &result) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandObjectProcessConnect() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessConnect(CommandInterpreter &interpreter)
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *exe_ctx) override
Set the value of an option.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessContinue(CommandInterpreter &interpreter)
~CommandObjectProcessContinue() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessDetach(CommandInterpreter &interpreter)
~CommandObjectProcessDetach() override=default
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
CommandObjectProcessHandle(CommandInterpreter &interpreter)
~CommandObjectProcessHandle() override=default
void DoExecute(Args &signal_args, CommandReturnObject &result) override
void PrintSignalInformation(Stream &str, Args &signal_args, int num_valid_signals, const UnixSignalsSP &signals_sp)
void PrintSignal(Stream &str, int32_t signo, llvm::StringRef sig_name, const UnixSignalsSP &signals_sp)
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessInterrupt(CommandInterpreter &interpreter)
~CommandObjectProcessInterrupt() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
~CommandObjectProcessKill() override=default
CommandObjectProcessKill(CommandInterpreter &interpreter)
bool StopProcessIfNecessary(Process *process, StateType &state, CommandReturnObject &result)
CommandObjectProcessLaunchOrAttach(CommandInterpreter &interpreter, const char *name, const char *help, const char *syntax, uint32_t flags, const char *new_process_action)
~CommandObjectProcessLaunchOrAttach() override=default
void DoExecute(Args &launch_args, CommandReturnObject &result) override
OptionGroupPythonClassWithDict m_class_options
std::optional< std::string > GetRepeatCommand(Args &current_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
~CommandObjectProcessLaunch() override=default
CommandOptionsProcessLaunch m_options
CommandObjectProcessLaunch(CommandInterpreter &interpreter)
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
~CommandObjectProcessLoad() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
void DoExecute(Args &command, CommandReturnObject &result) override
Options * GetOptions() override
CommandObjectProcessLoad(CommandInterpreter &interpreter)
~CommandObjectProcessPlugin() override=default
CommandObjectProcessPlugin(CommandInterpreter &interpreter)
CommandObject * GetProxyCommandObject() override
void OptionParsingStarting(ExecutionContext *execution_context) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandObjectProcessSaveCore() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessSaveCore(CommandInterpreter &interpreter)
CommandObjectProcessSignal(CommandInterpreter &interpreter)
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
~CommandObjectProcessSignal() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
CommandObjectProcessStatus(CommandInterpreter &interpreter)
~CommandObjectProcessStatus() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessTraceStart(CommandInterpreter &interpreter)
lldb::CommandObjectSP GetDelegateCommand(Trace &trace) override
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessTraceStop(CommandInterpreter &interpreter)
~CommandObjectProcessTraceStop() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessUnload(CommandInterpreter &interpreter)
~CommandObjectProcessUnload() override=default
void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector) override
The default version handles argument definitions that have only one argument type,...
An architecture specification class.
Definition: ArchSpec.h:31
bool IsValid() const
Tests if this ArchSpec is valid.
Definition: ArchSpec.h:348
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:450
bool IsExactMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, ExactMatch).
Definition: ArchSpec.h:497
A command line argument class.
Definition: Args.h:33
void AppendArguments(const Args &rhs)
Definition: Args.cpp:297
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
Definition: Args.h:116
void AppendArgument(llvm::StringRef arg_str, char quote_char='\0')
Appends a new argument to the end of the list argument list.
Definition: Args.cpp:322
llvm::ArrayRef< ArgEntry > entries() const
Definition: Args.h:128
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
Definition: Args.cpp:263
void Clear()
Clear the arguments.
Definition: Args.cpp:378
bool Contains(BreakpointID bp_id) const
bool AddBreakpointID(BreakpointID bp_id)
BreakpointID GetBreakpointIDAtIndex(size_t index) const
void SetBreakpointLocationID(lldb::break_id_t loc_id)
Definition: BreakpointID.h:44
lldb::break_id_t GetBreakpointID() const
Definition: BreakpointID.h:33
lldb::break_id_t GetLocationID() const
Definition: BreakpointID.h:35
General Outline: Allows adding and removing breakpoints and find by ID and index.
BreakpointIterable Breakpoints()
lldb::BreakpointSP FindBreakpointByID(lldb::break_id_t breakID) const
Returns a shared pointer to the breakpoint with id breakID.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
Definition: Breakpoint.h:81
void SetIgnoreCount(uint32_t count)
Set the breakpoint to ignore the next count breakpoint hits.
Definition: Breakpoint.cpp:301
bool IsInternal() const
Tell whether this breakpoint is an "internal" breakpoint.
Definition: Breakpoint.cpp:249
bool Confirm(llvm::StringRef message, bool default_answer)
bool HandleCommand(const char *command_line, LazyBool add_to_history, const ExecutionContext &override_context, CommandReturnObject &result)
ExecutionContext GetExecutionContext() const
lldb::PlatformSP GetPlatform(bool prefer_target_platform)
static void VerifyBreakpointOrLocationIDs(Args &args, Target &target, CommandReturnObject &result, BreakpointIDList *valid_ids, BreakpointName::Permissions ::PermissionKinds purpose)
CommandObjectMultiwordProcess(CommandInterpreter &interpreter)
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
This class works by delegating the logic to the actual trace plug-in that can support the current pro...
virtual void SetHelpLong(llvm::StringRef str)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
ExecutionContext m_exe_ctx
CommandInterpreter & m_interpreter
virtual void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector)
The default version handles argument definitions that have only one argument type,...
void AppendErrorWithFormatv(const char *format, Args &&... args)
void AppendMessage(llvm::StringRef in_string)
void void AppendError(llvm::StringRef in_string)
void AppendWarningWithFormat(const char *format,...) __attribute__((format(printf
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
void AppendMessageWithFormat(const char *format,...) __attribute__((format(printf
void void AppendWarning(llvm::StringRef in_string)
"lldb/Utility/ArgCompletionRequest.h"
void TryCompleteCurrentArg(llvm::StringRef completion, llvm::StringRef description="")
Adds a possible completion string if the completion would complete the current argument.
A class to manage flag bits.
Definition: Debugger.h:80
lldb::TargetSP GetSelectedTarget()
Definition: Debugger.h:185
void SetAsyncExecution(bool async)
Definition: Debugger.cpp:984
TargetList & GetTargetList()
Get accessor for the target list.
Definition: Debugger.h:198
std::pair< iterator, bool > insert(llvm::StringRef KeyEqValue)
Definition: Environment.h:71
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
bool HasProcessScope() const
Returns true the ExecutionContext object contains a valid target and process.
const lldb::ProcessSP & GetProcessSP() const
Get accessor to get the process shared pointer.
Process * GetProcessPtr() const
Returns a pointer to the process object.
A file utility class.
Definition: FileSpec.h:56
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
Definition: FileSpec.cpp:174
void Clear()
Clears the object state.
Definition: FileSpec.cpp:259
void Resolve(llvm::SmallVectorImpl< char > &path)
Resolve path to make it canonical.
static FileSystem & Instance()
ValueType Clear(ValueType mask=~static_cast< ValueType >(0))
Clear one or more flags.
Definition: Flags.h:61
ValueType Set(ValueType mask)
Set one or more flags by logical OR'ing mask with the current flags.
Definition: Flags.h:73
void Append(OptionGroup *group)
Append options from a OptionGroup class.
Definition: Options.cpp:755
const StructuredData::DictionarySP GetStructuredData()
A command line option parsing protocol class.
Definition: Options.h:58
std::vector< Option > m_getopt_table
Definition: Options.h:198
static Status SaveCore(const lldb::ProcessSP &process_sp, lldb_private::SaveCoreOptions &core_options)
void SetProcessPluginName(llvm::StringRef plugin)
Definition: Process.h:160
bool GetContinueOnceAttached() const
Definition: Process.h:148
void SetExecutableFile(const FileSpec &exe_file, bool add_exe_file_as_first_arg)
Definition: ProcessInfo.cpp:65
void SetScriptedMetadata(lldb::ScriptedMetadataSP metadata_sp)
Definition: ProcessInfo.h:97
FileSpec & GetExecutableFile()
Definition: ProcessInfo.h:43
Environment & GetEnvironment()
Definition: ProcessInfo.h:88
void SetProcessPluginName(llvm::StringRef plugin)
bool GetDetachKeepsStopped() const
Definition: Process.cpp:319
A plug-in interface definition class for debugging a process.
Definition: Process.h:341
StopPointSiteList< lldb_private::BreakpointSite > & GetBreakpointSiteList()
Definition: Process.cpp:1610
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:540
Status Destroy(bool force_kill)
Kills the process and shuts down all threads that were spawned to track and monitor the process.
Definition: Process.cpp:3495
ThreadList & GetThreadList()
Definition: Process.h:2227
Status Resume()
Resumes all of a process's threads as configured using the Thread run control functions.
Definition: Process.cpp:1382
Status ResumeSynchronous(Stream *stream)
Resume a process, and wait for it to stop.
Definition: Process.cpp:1399
size_t GetThreadStatus(Stream &ostrm, bool only_threads_with_stop_reason, uint32_t start_frame, uint32_t num_frames, uint32_t num_frames_with_source, bool stop_format)
Definition: Process.cpp:5789
Status Detach(bool keep_stopped)
Detaches from a running or stopped process.
Definition: Process.cpp:3443
Status Signal(int signal)
Sends a process a UNIX signal signal.
Definition: Process.cpp:3576
lldb::StateType GetState()
Get accessor for the current process state.
Definition: Process.cpp:1335
void GetStatus(Stream &ostrm)
Definition: Process.cpp:5769
uint32_t GetIOHandlerID() const
Definition: Process.h:2289
bool GetShouldDetach() const
Definition: Process.h:789
const std::vector< lldb::addr_t > & GetImageTokens()
Get the image vector for the current process.
Definition: Process.h:797
virtual bool IsAlive()
Check if a process is still alive.
Definition: Process.cpp:1127
virtual ArchSpec GetSystemArchitecture()
Get the system architecture for this process.
Definition: Process.h:755
virtual CommandObject * GetPluginCommandObject()
Return a multi-word command object that can be used to expose plug-in specific commands.
Definition: Process.h:589
void SyncIOHandler(uint32_t iohandler_id, const Timeout< std::micro > &timeout)
Waits for the process state to be running within a given msec timeout.
Definition: Process.cpp:663
lldb::addr_t GetDataAddressMask()
Definition: Process.cpp:5901
const lldb::UnixSignalsSP & GetUnixSignals()
Definition: Process.cpp:3591
lldb::addr_t GetCodeAddressMask()
Get the current address mask in the Process.
Definition: Process.cpp:5894
Status Halt(bool clear_thread_plans=false, bool use_run_lock=true)
Halts a running process.
Definition: Process.cpp:3318
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1285
lldb_private::Status SetPluginName(const char *name)
void SetStyle(lldb::SaveCoreStyle style)
void SetOutputFile(lldb_private::FileSpec file)
An error handling class.
Definition: Status.h:44
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:129
bool Success() const
Test for success condition.
Definition: Status.cpp:278
StopPointSiteSP FindByID(typename StopPointSite::SiteID site_id)
Returns a shared pointer to the site with id site_id.
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
void Format(const char *format, Args &&... args)
Definition: Stream.h:353
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition: Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:65
size_t EOL()
Output and End of Line character to the stream.
Definition: Stream.cpp:155
std::shared_ptr< Dictionary > DictionarySP
Status CreateTarget(Debugger &debugger, llvm::StringRef user_exe_path, llvm::StringRef triple_str, LoadDependentFiles get_dependent_modules, const OptionGroupPlatform *platform_options, lldb::TargetSP &target_sp)
Create a new Target.
Definition: TargetList.cpp:45
llvm::StringRef GetArg0() const
Definition: Target.cpp:4365
void SetRunArguments(const Args &args)
Definition: Target.cpp:4382
const ProcessLaunchInfo & GetProcessLaunchInfo() const
Definition: Target.cpp:4794
Environment GetEnvironment() const
Definition: Target.cpp:4416
void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info)
Definition: Target.cpp:4798
void ClearDummySignals(Args &signal_names)
Clear the dummy signals in signal_names from the target, or all signals if signal_names is empty.
Definition: Target.cpp:3645
BreakpointList & GetBreakpointList(bool internal=false)
Definition: Target.cpp:315
const lldb::ProcessSP & GetProcessSP() const
Definition: Target.cpp:222
Status Launch(ProcessLaunchInfo &launch_info, Stream *stream)
Definition: Target.cpp:3208
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
Definition: Target.cpp:1423
lldb::PlatformSP GetPlatform()
Definition: Target.h:1449
const ArchSpec & GetArchitecture() const
Definition: Target.h:1028
void AddDummySignal(llvm::StringRef name, LazyBool pass, LazyBool print, LazyBool stop)
Add a signal to the Target's list of stored signals/actions.
Definition: Target.cpp:3576
void PrintDummySignals(Stream &strm, Args &signals)
Print all the signals set in this target.
Definition: Target.cpp:3670
Status Attach(ProcessAttachInfo &attach_info, Stream *stream)
Definition: Target.cpp:3411
uint32_t GetSize(bool can_update=true)
Definition: ThreadList.cpp:82
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
Definition: ThreadList.cpp:90
std::recursive_mutex & GetMutex() const override
Definition: ThreadList.cpp:787
A plug-in interface definition class for trace information.
Definition: Trace.h:48
virtual lldb::CommandObjectSP GetProcessTraceStartCommand(CommandInterpreter &interpreter)=0
Get the command handle for the "process trace start" command.
#define LLDB_OPT_SET_1
Definition: lldb-defines.h:111
#define LLDB_OPT_SET_2
Definition: lldb-defines.h:112
#define LLDB_INVALID_BREAK_ID
Definition: lldb-defines.h:37
#define LLDB_INVALID_ADDRESS_MASK
Address Mask Bits not used for addressing are set to 1 in the mask; all mask bits set is an invalid v...
Definition: lldb-defines.h:133
#define LLDB_INVALID_SIGNAL_NUMBER
Definition: lldb-defines.h:92
#define LLDB_OPT_SET_ALL
Definition: lldb-defines.h:110
#define LLDB_INVALID_IMAGE_TOKEN
Definition: lldb-defines.h:85
A class that represents a running process on the host machine.
std::vector< OptionArgElement > OptionElementVector
Definition: Options.h:43
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
Definition: State.cpp:14
const char * toString(AppleArm64ExceptionClass EC)
static uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit)
Definition: ARMUtils.h:265
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::Trace > TraceSP
Definition: lldb-forward.h:454
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
Definition: lldb-forward.h:321
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
Definition: lldb-forward.h:322
@ eSaveCoreUnspecified
std::shared_ptr< lldb_private::Thread > ThreadSP
Definition: lldb-forward.h:446
std::shared_ptr< lldb_private::ScriptedMetadata > ScriptedMetadataSP
Definition: lldb-forward.h:405
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
Definition: lldb-forward.h:331
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
Definition: lldb-forward.h:476
std::shared_ptr< lldb_private::Platform > PlatformSP
Definition: lldb-forward.h:386
StateType
Process and Thread States.
@ eStateConnected
Process is connected to remote debug services, but not launched or attached to anything yet.
@ eStateStopped
Process or thread is stopped and can be examined.
@ eStateRunning
Process or thread is running and can't be examined.
@ eStateAttaching
Process is currently trying to attach.
std::shared_ptr< lldb_private::Breakpoint > BreakpointSP
Definition: lldb-forward.h:319
int32_t break_id_t
Definition: lldb-types.h:86
std::shared_ptr< lldb_private::Process > ProcessSP
Definition: lldb-forward.h:387
@ eReturnStatusFailed
@ eReturnStatusSuccessContinuingNoResult
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
@ eArgTypeConnectURL
@ eArgTypeUnsignedInteger
@ eArgTypeUnixSignal
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
Definition: lldb-forward.h:427
uint64_t addr_t
Definition: lldb-types.h:80
@ eStopReasonBreakpoint
std::shared_ptr< lldb_private::Target > TargetSP
Definition: lldb-forward.h:444
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:371
static int64_t ToOptionEnum(llvm::StringRef s, const OptionEnumValues &enum_values, int32_t fail_value, Status &error)
static bool ToBoolean(llvm::StringRef s, bool fail_value, bool *success_ptr)