38#include "llvm/Support/FormatAdapters.h"
40#include "llvm/ADT/ScopeExit.h"
51 const char *name,
const char *help,
52 const char *syntax, uint32_t flags,
53 const char *new_process_action)
70 llvm::formatv(
"There is a pending attach, abort it and {0}?",
73 message = llvm::formatv(
74 "There is a running process, detach from it and {0}?",
78 llvm::formatv(
"There is a running process, kill it and {0}?",
86 bool keep_stopped =
false;
115#pragma mark CommandObjectProcessLaunch
120 interpreter,
"process launch",
121 "Launch the executable in the debugger. If no run-args are "
122 "specified, the arguments from target.run-args are used.",
123 nullptr, eCommandRequiresTarget,
"restart"),
139 uint32_t index)
override {
141 return std::string(
"");
157 result.
AppendError(
"no file in target, create a debug target using the "
158 "'target create' command");
172 bool disable_aslr =
false;
184 m_options.launch_info.SetProcessPluginName(
"ScriptedProcess");
187 m_options.launch_info.SetScriptedMetadata(metadata_sp);
192 m_options.launch_info.GetFlags().Set(eLaunchFlagDisableASLR);
194 m_options.launch_info.GetFlags().Clear(eLaunchFlagDisableASLR);
197 m_options.launch_info.GetFlags().Set(eLaunchFlagInheritTCCFromParent);
200 m_options.launch_info.GetFlags().Set(eLaunchFlagDetachOnError);
203 m_options.launch_info.GetFlags().Set(eLaunchFlagDisableSTDIO);
205 if (!
m_options.launch_info.GetWorkingDirectory()) {
214 m_options.launch_info.GetEnvironment().insert(target_env.begin(),
217 llvm::StringRef target_settings_argv0 = target->
GetArg0();
219 if (!target_settings_argv0.empty()) {
220 m_options.launch_info.GetArguments().AppendArgument(
221 target_settings_argv0);
224 exe_module_sp->GetPlatformFileSpec(),
false);
230 exe_module_sp->GetPlatformFileSpec(),
true);
236 m_options.launch_info.GetArguments().AppendArguments(
239 m_options.launch_info.GetArguments().AppendArguments(launch_args);
247 if (
error.Success()) {
254 process_sp->SyncIOHandler(0, std::chrono::seconds(2));
260 if (!exe_module_sp) {
261 result.
AppendWarning(
"could not get executable module after launch");
264 const char *archname =
265 exe_module_sp->GetArchitecture().GetArchitectureName();
267 "Process {0} launched: '{1}' ({2})", process_sp->GetID(),
268 exe_module_sp->GetFileSpec().GetPath().c_str(), archname);
273 llvm::StringRef data = stream.
GetString();
279 "no error returned from Target::Launch, and target has no process");
291#define LLDB_OPTIONS_process_attach
292#include "CommandOptions.inc"
294#pragma mark CommandObjectProcessAttach
299 interpreter,
"process attach",
"Attach to a process.",
300 "process attach <cmd-options>", 0,
"attach"),
315 GetDebugger().GetPlatformList().GetSelectedPlatform());
329 if (target ==
nullptr) {
338 target = new_target_sp.get();
339 if (target ==
nullptr ||
error.Fail()) {
346 m_options.attach_info.SetProcessPluginName(
"ScriptedProcess");
349 m_options.attach_info.SetScriptedMetadata(metadata_sp);
362 if (
error.Success()) {
370 "no error returned from Target::Attach, and target has no process");
382 if (!old_exec_module_sp) {
384 if (new_exec_module_sp) {
386 "Executable binary set to \"{0}\".",
387 new_exec_module_sp->GetFileSpec().GetPath().c_str());
389 }
else if (!new_exec_module_sp) {
391 }
else if (old_exec_module_sp->GetFileSpec() !=
392 new_exec_module_sp->GetFileSpec()) {
395 "executable binary changed from \"{0}\" to \"{1}\"",
396 old_exec_module_sp->GetFileSpec().GetPath(),
397 new_exec_module_sp->GetFileSpec().GetPath());
400 if (!old_arch_spec.
IsValid()) {
402 "Architecture set to: {0}.",
406 "architecture changed from {0} to {1}",
413 if (
m_options.attach_info.GetContinueOnceAttached()) {
429#define LLDB_OPTIONS_process_continue
430#include "CommandOptions.inc"
432#pragma mark CommandObjectProcessContinue
438 interpreter,
"process continue",
439 "Continue execution of all threads in the current process.",
441 eCommandRequiresProcess | eCommandTryTargetAPILock |
442 eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {}
461 switch (short_option) {
463 if (option_arg.getAsInteger(0,
m_ignore))
465 "invalid value for ignore option: \"%s\", should be a number.",
466 option_arg.str().c_str());
479 llvm_unreachable(
"Unimplemented option");
492 return llvm::ArrayRef(g_process_continue_options);
509 StopInfoSP stop_info_sp = sel_thread_sp->GetStopInfo();
517 const size_t num_owners = bp_site_sp->GetNumberOfConstituents();
518 for (
size_t i = 0; i < num_owners; i++) {
520 bp_site_sp->GetConstituentAtIndex(i)->GetBreakpoint();
534 if (
m_options.m_run_to_bkpt_args.GetArgumentCount() > 0)
543 result.
AppendError(
"continue-to breakpoints did not specify any actual "
544 "breakpoints or locations");
550 size_t num_run_to_bkpt_ids = run_to_bkpt_ids.
GetSize();
551 std::vector<break_id_t> bkpts_disabled;
552 std::vector<BreakpointID> locs_disabled;
553 if (num_run_to_bkpt_ids != 0) {
559 std::unordered_set<break_id_t> bkpts_seen;
560 std::unordered_set<break_id_t> bkpts_with_locs_seen;
562 bool any_enabled =
false;
564 for (
size_t idx = 0; idx < num_run_to_bkpt_ids; idx++) {
572 if (bp_sp->IsEnabled()) {
576 size_t num_locations = bp_sp->GetNumLocations();
577 for (
size_t loc_idx = 0; loc_idx < num_locations; loc_idx++) {
579 = bp_sp->GetLocationAtIndex(loc_idx);
580 if (loc_sp->IsEnabled()) {
588 if (loc_sp->IsEnabled())
606 result.
AppendError(
"at least one of the continue-to breakpoints must "
615 for (
break_id_t bp_id : bkpts_with_locs_seen) {
616 if (bkpts_seen.count(bp_id)) {
618 "one of its locations: {0}", bp_id);
629 if (!bkpts_with_locs_seen.count(bp_id)) {
630 if (!bkpts_seen.count(bp_id) && bp_sp->IsEnabled()) {
631 bkpts_disabled.push_back(bp_id);
632 bp_sp->SetEnabled(
false);
639 size_t num_locations = bp_sp->GetNumLocations();
641 for (
size_t loc_idx = 0; loc_idx < num_locations; loc_idx++) {
644 if (!with_locs.
Contains(tmp_id) && loc_sp->IsEnabled()) {
645 if (llvm::Error
error = loc_sp->SetEnabled(
false))
647 "failed to disable breakpoint location: {0}",
648 llvm::fmt_consume(std::move(
error)));
650 locs_disabled.push_back(tmp_id);
657 std::lock_guard<std::recursive_mutex> guard(
662 for (uint32_t idx = 0; idx < num_threads; ++idx) {
663 const bool override_suspend =
false;
669 if (
m_options.m_base_direction.has_value())
679 if (run_to_bkpt_ids.
GetSize() != 0) {
681 synchronous_execution =
true;
683 if (synchronous_execution)
688 if (run_to_bkpt_ids.
GetSize() != 0) {
697 bp_sp->SetEnabled(
true);
704 = bp_sp->FindLocationByID(bkpt_id.GetLocationID());
706 if (llvm::Error
error = loc_sp->SetEnabled(
true))
708 "failed to enable breakpoint location: {0}",
709 llvm::fmt_consume(std::move(
error)));
714 if (
error.Success()) {
719 process->
SyncIOHandler(iohandler_id, std::chrono::seconds(2));
723 if (synchronous_execution) {
739 "Process cannot be continued from its current state (%s)",
750#define LLDB_OPTIONS_process_detach
751#include "CommandOptions.inc"
753#pragma mark CommandObjectProcessDetach
768 switch (short_option) {
775 "invalid boolean option: \"%s\"", option_arg.str().c_str());
784 llvm_unreachable(
"Unimplemented option");
794 return llvm::ArrayRef(g_process_detach_options);
803 "Detach from the current target process.",
805 eCommandRequiresProcess | eCommandTryTargetAPILock |
806 eCommandProcessMustBeLaunched) {}
823 keep_stopped =
false;
826 if (
error.Success()) {
837#define LLDB_OPTIONS_process_connect
838#include "CommandOptions.inc"
840#pragma mark CommandObjectProcessConnect
859 switch (short_option) {
865 llvm_unreachable(
"Unimplemented option");
875 return llvm::ArrayRef(g_process_connect_options);
885 "Connect to a remote debug service.",
886 "process connect <remote-url>", 0) {
898 "'%s' takes exactly one argument:\nUsage: %s",
m_cmd_name.c_str(),
904 if (process && process->
IsAlive()) {
907 " is currently being debugged, kill the process before connecting.",
912 const char *plugin_name =
nullptr;
914 plugin_name =
m_options.plugin_name.c_str();
921 ? platform_sp->ConnectProcess(
924 : platform_sp->ConnectProcessSynchronous(
928 if (
error.Fail() || process_sp ==
nullptr) {
939#pragma mark CommandObjectProcessPlugin
945 interpreter,
"process plugin",
946 "Send a custom command to the current target process plug-in.",
947 "process plugin <args>", 0) {}
959 return "no process plugin commands are currently registered";
964#define LLDB_OPTIONS_process_load
965#include "CommandOptions.inc"
967#pragma mark CommandObjectProcessLoad
987 switch (short_option) {
990 if (!option_arg.empty())
994 llvm_unreachable(
"Unimplemented option");
1005 return llvm::ArrayRef(g_process_load_options);
1015 "Load a shared library into the current process.",
1016 "process load <filename> [<filename> ...]",
1017 eCommandRequiresProcess | eCommandTryTargetAPILock |
1018 eCommandProcessMustBeLaunched |
1019 eCommandProcessMustBePaused) {
1039 for (
auto &entry : command.
entries()) {
1042 llvm::StringRef image_path = entry.ref();
1047 platform->ResolveRemotePath(image_spec, image_spec);
1049 platform->LoadImage(process,
FileSpec(), image_spec,
error);
1053 platform->ResolveRemotePath(
m_options.install_path,
1055 image_token = platform->LoadImage(process, image_spec,
1061 platform->LoadImage(process, image_spec,
FileSpec(),
error);
1066 "Loading \"{0}\"...ok\nImage {1} loaded.", image_path.str().c_str(),
1071 image_path.str().c_str(),
1081#pragma mark CommandObjectProcessUnload
1087 interpreter,
"process unload",
1088 "Unload a shared library from the current process using the index "
1089 "returned by a previous call to \"process load\".",
1090 "process unload <index>",
1091 eCommandRequiresProcess | eCommandTryTargetAPILock |
1092 eCommandProcessMustBeLaunched | eCommandProcessMustBePaused) {
1107 const std::vector<addr_t> &token_addrs = process->
GetImageTokens();
1108 const size_t token_num = token_addrs.size();
1109 for (
size_t i = 0; i < token_num; ++i) {
1120 for (
auto &entry : command.
entries()) {
1121 uint32_t image_token;
1122 if (entry.ref().getAsInteger(0, image_token)) {
1124 entry.ref().str().c_str());
1128 process, image_token));
1129 if (
error.Success()) {
1131 "Unloading shared library with index {0}...ok", image_token);
1144#pragma mark CommandObjectProcessSignal
1150 interpreter,
"process signal",
1151 "Send a UNIX signal to the current target process.", nullptr,
1152 eCommandRequiresProcess | eCommandTryTargetAPILock) {
1165 int signo = signals->GetFirstSignalNumber();
1168 signo = signals->GetNextSignalNumber(signo);
1180 if (::isxdigit(signal_name[0])) {
1181 if (!llvm::to_integer(signal_name, signo))
1184 signo = process->
GetUnixSignals()->GetSignalNumberFromName(signal_name);
1191 if (
error.Success()) {
1200 "'%s' takes exactly one signal number argument:\nUsage: %s",
1207#pragma mark CommandObjectProcessInterrupt
1213 "Interrupt the current target process.",
1214 "process interrupt",
1215 eCommandRequiresProcess | eCommandTryTargetAPILock |
1216 eCommandProcessMustBeLaunched) {}
1223 if (process ==
nullptr) {
1228 bool clear_thread_plans =
true;
1230 if (
error.Success()) {
1240#pragma mark CommandObjectProcessKill
1246 "Terminate the current target process.",
1248 eCommandRequiresProcess | eCommandTryTargetAPILock |
1249 eCommandProcessMustBeLaunched) {}
1256 if (process ==
nullptr) {
1262 if (
error.Success()) {
1271#define LLDB_OPTIONS_process_save_core
1272#include "CommandOptions.inc"
1278 interpreter,
"process save-core",
1279 "Save the current process as a core file using an "
1280 "appropriate file type.",
1281 "process save-core [-s corefile-style -p plugin-name] FILE",
1282 eCommandRequiresProcess | eCommandTryTargetAPILock |
1283 eCommandProcessMustBeLaunched) {
1301 auto orig = llvm::ArrayRef(g_process_save_core_options);
1303 llvm::copy(g_process_save_core_options,
m_opt_def.data());
1305 llvm::StringRef opt_name = value.long_option;
1306 if (opt_name !=
"plugin-name")
1309 llvm::SmallVector<llvm::StringRef> plugin_names =
1312 for (
auto [num, val] : llvm::zip(plugin_names,
m_plugin_enums)) {
1313 val.string_value = num.data();
1326 switch (short_option) {
1337 llvm_unreachable(
"Unimplemented option");
1361 auto &core_dump_options =
m_options.m_core_dump_options;
1362 core_dump_options.SetOutputFile(output_file);
1363 core_dump_options.SetProcess(process_sp);
1365 if (
error.Success()) {
1366 if (core_dump_options.GetStyle() ==
1368 core_dump_options.GetStyle() ==
1371 "\nModified-memory or stack-memory only corefile "
1372 "created. This corefile may \n"
1373 "not show library/framework/app binaries "
1374 "on a different system, or when \n"
1375 "those binaries have "
1376 "been updated/modified. Copies are not included\n"
1377 "in this corefile. Use --style full to include all "
1383 "failed to save core file for process to '{0}': {1}\n",
1399#pragma mark CommandObjectProcessStatus
1400#define LLDB_OPTIONS_process_status
1401#include "CommandOptions.inc"
1407 interpreter,
"process status",
1408 "Show status and stop location for the current target process.",
1410 eCommandRequiresProcess | eCommandTryTargetAPILock) {}
1426 switch (short_option) {
1434 llvm_unreachable(
"Unimplemented option");
1446 return llvm::ArrayRef(g_process_status_options);
1462 const bool only_threads_with_stop_reason =
true;
1463 const uint32_t start_frame = 0;
1464 const uint32_t num_frames = 1;
1465 const uint32_t num_frames_with_source = 1;
1466 const bool stop_format =
true;
1468 process->
GetThreadStatus(strm, only_threads_with_stop_reason, start_frame,
1469 num_frames, num_frames_with_source, stop_format);
1475 int bits = std::bitset<64>(~code_mask).count();
1481 "Number of bits used in addressing (code): {0}",
bits);
1486 result.
AppendError(
"Couldn't retrieve the target's platform");
1490 auto expected_crash_info =
1491 platform_sp->FetchExtendedCrashInformation(*process);
1493 if (!expected_crash_info) {
1494 result.
AppendError(llvm::toString(expected_crash_info.takeError()));
1500 if (crash_info_sp) {
1502 strm.
PutCString(
"Extended Crash Information:\n");
1503 crash_info_sp->GetDescription(strm);
1521#define LLDB_OPTIONS_process_handle
1522#include "CommandOptions.inc"
1524#pragma mark CommandObjectProcessHandle
1539 switch (short_option) {
1547 stop = std::string(option_arg);
1550 notify = std::string(option_arg);
1553 pass = std::string(option_arg);
1559 llvm_unreachable(
"Unimplemented option");
1574 return llvm::ArrayRef(g_process_handle_options);
1589 "Manage LLDB handling of OS signals for the "
1590 "current target process. Defaults to showing "
1593 SetHelpLong(
"\nIf no signals are specified but one or more actions are, "
1594 "and there is a live process, update them all. If no action "
1595 "is specified, list the current values.\n"
1596 "If you specify actions with no target (e.g. in an init file) "
1597 "or in a target with no process "
1598 "the values will get copied into subsequent targets, but "
1599 "lldb won't be able to spell-check the options since it can't "
1600 "know which signal set will later be in force."
1601 "\nYou can see the signal modifications held by the target"
1602 "by passing the -t option."
1603 "\nYou can also clear the target modification for a signal"
1604 "by passing the -c option");
1613 str.
Printf(
"NAME PASS STOP NOTIFY DESCRIPTION\n");
1614 str.
Printf(
"=========== ===== ===== ====== ===================\n");
1623 str.
Format(
"{0, -11} ", sig_name);
1624 if (signals_sp->GetSignalInfo(signo, suppress, stop, notify)) {
1625 const bool pass = !suppress;
1626 str.
Printf(
"%s %s %s", (pass ?
"true " :
"false"),
1627 (stop ?
"true " :
"false"), (notify ?
"true " :
"false"));
1629 const llvm::StringRef sig_description =
1630 signals_sp->GetSignalNumberDescription(signo);
1631 if (!sig_description.empty()) {
1640 int num_valid_signals,
1644 if (num_valid_signals > 0) {
1646 for (
size_t i = 0; i < num_args; ++i) {
1647 int32_t signo = signals_sp->GetSignalNumberFromName(
1655 int32_t signo = signals_sp->GetFirstSignalNumber();
1657 PrintSignal(str, signo, signals_sp->GetSignalAsStringRef(signo),
1659 signo = signals_sp->GetNextSignalNumber(signo);
1674 std::optional<bool> stop_action = {};
1675 std::optional<bool> pass_action = {};
1676 std::optional<bool> notify_action = {};
1679 bool success =
false;
1683 "Invalid argument for command option --stop; must be "
1684 "true or false.\n");
1688 stop_action = value;
1692 bool success =
false;
1696 "Invalid argument for command option --pass; must be "
1697 "true or false.\n");
1700 pass_action = value;
1704 bool success =
false;
1708 result.
AppendError(
"Invalid argument for command option --notify; must "
1709 "be true or false.\n");
1712 notify_action = value;
1715 if (!
m_options.notify.empty() && !notify_action.has_value()) {
1718 bool no_actions = (!stop_action.has_value() && !pass_action.has_value() &&
1719 !notify_action.has_value());
1720 if (
m_options.only_target_values && !no_actions) {
1721 result.
AppendError(
"-t is for reporting, not setting, target values.");
1728 signals_sp = process_sp->GetUnixSignals();
1730 int num_signals_set = 0;
1751 for (
const auto &arg : signal_args) {
1755 int32_t signo = signals_sp->GetSignalNumberFromName(arg.c_str());
1757 if (stop_action.has_value())
1758 signals_sp->SetShouldStop(signo, *stop_action);
1759 if (pass_action.has_value()) {
1760 bool suppress = !*pass_action;
1761 signals_sp->SetShouldSuppress(signo, suppress);
1763 if (notify_action.has_value())
1764 signals_sp->SetShouldNotify(signo, *notify_action);
1777 if (llvm::to_integer(arg.c_str(), signo)) {
1779 "number with no process");
1782 num_signals_set = num_args;
1784 auto set_lazy_bool = [](std::optional<bool> action) ->
LazyBool {
1785 if (!action.has_value())
1793 set_lazy_bool(notify_action),
1794 set_lazy_bool(stop_action));
1800 if ((notify_action.has_value() || stop_action.has_value() ||
1801 pass_action.has_value()) &&
1804 "Do you really want to update all the signals?",
false)) {
1805 int32_t signo = signals_sp->GetFirstSignalNumber();
1807 if (notify_action.has_value())
1808 signals_sp->SetShouldNotify(signo, *notify_action);
1809 if (stop_action.has_value())
1810 signals_sp->SetShouldStop(signo, *stop_action);
1811 if (pass_action.has_value()) {
1812 bool suppress = !*pass_action;
1813 signals_sp->SetShouldSuppress(signo, suppress);
1815 signo = signals_sp->GetNextSignalNumber(signo);
1823 num_signals_set, signals_sp);
1828 if (num_signals_set > 0)
1845 "process trace start",
1846 "Start tracing this process with the corresponding trace "
1848 "process trace start [<trace-options>]") {}
1861 "Stop tracing this process. This does not affect "
1862 "traces started with the "
1863 "\"thread trace start\" command.",
1864 "process trace stop",
1865 eCommandRequiresProcess | eCommandTryTargetAPILock |
1866 eCommandProcessMustBeLaunched |
1867 eCommandProcessMustBePaused |
1868 eCommandProcessMustBeTraced) {}
1875 TraceSP trace_sp = process_sp->GetTarget().GetTrace();
1877 if (llvm::Error err = trace_sp->Stop())
1889 interpreter,
"trace",
"Commands for tracing the current process.",
1890 "process trace <subcommand> [<subcommand objects>]") {
1905 interpreter,
"process",
1906 "Commands for interacting with processes on the current platform.",
1907 "process <subcommand> [<subcommand-options>]") {
static llvm::raw_ostream & error(Stream &strm)
~CommandObjectMultiwordProcessTrace() override=default
CommandObjectMultiwordProcessTrace(CommandInterpreter &interpreter)
CommandOptionsProcessAttach m_options
~CommandObjectProcessAttach() override=default
OptionGroupOptions m_all_options
OptionGroupPythonClassWithDict m_class_options
CommandObjectProcessAttach(CommandInterpreter &interpreter)
Options * GetOptions() override
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
~CommandOptions() override=default
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
~CommandObjectProcessConnect() override=default
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessConnect(CommandInterpreter &interpreter)
Options * GetOptions() override
~CommandOptions() override=default
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
bool m_any_bkpts_specified
std::optional< lldb::RunDirection > m_base_direction
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessContinue(CommandInterpreter &interpreter)
~CommandObjectProcessContinue() override=default
Options * GetOptions() override
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.
~CommandOptions() override=default
Options * GetOptions() override
void DoExecute(Args &command, CommandReturnObject &result) override
CommandObjectProcessDetach(CommandInterpreter &interpreter)
~CommandObjectProcessDetach() override=default
~CommandOptions() 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 PrintSignalHeader(Stream &str)
Options * GetOptions() override
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)
std::string m_new_process_action
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 ¤t_command_args, uint32_t index) override
Get the command that appropriate for a "repeat" of the current command.
OptionGroupOptions m_all_options
~CommandObjectProcessLaunch() override=default
Options * GetOptions() override
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.
~CommandOptions() override=default
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
llvm::StringRef GetUnsupportedError() override
void OptionParsingStarting(ExecutionContext *execution_context) override
llvm::SmallVector< OptionEnumValueElement > m_plugin_enums
~CommandOptions() override=default
SaveCoreOptions m_core_dump_options
std::vector< OptionDefinition > m_opt_def
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
Options * GetOptions() 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
~CommandOptions() override=default
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
Options * GetOptions() 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.
bool IsValid() const
Tests if this ArchSpec is valid.
llvm::Triple & GetTriple()
Architecture triple accessor.
bool IsExactMatch(const ArchSpec &rhs) const
Shorthand for IsMatch(rhs, ExactMatch).
A command line argument class.
size_t GetArgumentCount() const
Gets the number of arguments left in this command object.
llvm::ArrayRef< ArgEntry > entries() const
const char * GetArgumentAtIndex(size_t idx) const
Gets the NULL terminated C string argument pointer for the argument at index idx.
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)
lldb::break_id_t GetBreakpointID() const
lldb::break_id_t GetLocationID() const
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...
void SetIgnoreCount(uint32_t count)
Set the breakpoint to ignore the next count breakpoint hits.
bool IsInternal() const
Tell whether this breakpoint is an "internal" breakpoint.
static void VerifyBreakpointOrLocationIDs(Args &args, ExecutionContext &exe_ctx, CommandReturnObject &result, BreakpointIDList *valid_ids, BreakpointName::Permissions ::PermissionKinds purpose)
CommandObjectMultiwordProcess(CommandInterpreter &interpreter)
~CommandObjectMultiwordProcess() override
bool LoadSubCommand(llvm::StringRef cmd_name, const lldb::CommandObjectSP &command_obj) override
CommandObjectMultiword(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
friend class CommandInterpreter
CommandObjectParsed(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
CommandObjectProxy(CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
friend class CommandInterpreter
CommandObjectTraceProxy(bool live_debug_session_only, CommandInterpreter &interpreter, const char *name, const char *help=nullptr, const char *syntax=nullptr, uint32_t flags=0)
virtual void SetHelpLong(llvm::StringRef str)
void AddSimpleArgumentList(lldb::CommandArgumentType arg_type, ArgumentRepetitionType repetition_type=eArgRepeatPlain)
Target & GetDummyTarget()
ExecutionContext m_exe_ctx
CommandInterpreter & m_interpreter
Thread * GetDefaultThread()
virtual void HandleArgumentCompletion(CompletionRequest &request, OptionElementVector &opt_element_vector)
The default version handles argument definitions that have only one argument type,...
void AppendMessage(llvm::StringRef in_string)
void AppendError(llvm::StringRef in_string)
void AppendWarningWithFormatv(const char *format, Args &&...args)
void SetStatus(lldb::ReturnStatus status)
void AppendErrorWithFormat(const char *format,...) __attribute__((format(printf
void void AppendMessageWithFormatv(const char *format, Args &&...args)
void SetDidChangeProcessState(bool b)
void AppendWarning(llvm::StringRef in_string)
void AppendErrorWithFormatv(const char *format, Args &&...args)
Stream & GetOutputStream()
"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.
size_t GetCursorIndex() const
A class to manage flag bits.
lldb::TargetSP GetSelectedTarget()
void SetAsyncExecution(bool async)
TargetList & GetTargetList()
Get accessor for the target list.
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
Process * GetProcessPtr() const
Returns a pointer to the process object.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
static FileSystem & Instance()
void Resolve(llvm::SmallVectorImpl< char > &path, bool force_make_absolute=false)
Resolve path to make it canonical.
A command line option parsing protocol class.
std::vector< Option > m_getopt_table
static Status SaveCore(lldb_private::SaveCoreOptions &core_options)
static llvm::SmallVector< llvm::StringRef > GetSaveCorePluginNames()
FileSpec & GetExecutableFile()
void Dump(Stream &stream) const
bool GetDetachKeepsStopped() const
A plug-in interface definition class for debugging a process.
StopPointSiteList< lldb_private::BreakpointSite > & GetBreakpointSiteList()
lldb::pid_t GetID() const
Returns the pid of the process or LLDB_INVALID_PROCESS_ID if there is no known pid.
Status Destroy(bool force_kill)
Kills the process and shuts down all threads that were spawned to track and monitor the process.
ThreadList & GetThreadList()
Status Resume()
Resumes all of a process's threads as configured using the Thread run control functions.
ProcessModID GetModID() const
Get the Modification ID of the process.
Status ResumeSynchronous(Stream *stream)
Resume a process, and wait for it to stop.
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)
Status Detach(bool keep_stopped)
Detaches from a running or stopped process.
Status Signal(int signal)
Sends a process a UNIX signal signal.
lldb::StateType GetState()
Get accessor for the current process state.
void GetStatus(Stream &ostrm)
uint32_t GetIOHandlerID() const
bool GetShouldDetach() const
const std::vector< lldb::addr_t > & GetImageTokens()
Get the image vector for the current process.
virtual bool IsAlive()
Check if a process is still alive.
virtual ArchSpec GetSystemArchitecture()
Get the system architecture for this process.
virtual CommandObject * GetPluginCommandObject()
Return a multi-word command object that can be used to expose plug-in specific commands.
void SyncIOHandler(uint32_t iohandler_id, const Timeout< std::micro > &timeout)
Waits for the process state to be running within a given msec timeout.
lldb::addr_t GetDataAddressMask()
const lldb::UnixSignalsSP & GetUnixSignals()
void SetBaseDirection(lldb::RunDirection direction)
Set the base run direction for the process.
lldb::addr_t GetCodeAddressMask()
Get the current address mask in the Process.
Status Halt(bool clear_thread_plans=false, bool use_run_lock=true)
Halts a running process.
Target & GetTarget()
Get the target object pointer for this module.
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
bool Success() const
Test for success condition.
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.
void Format(const char *format, Args &&... args)
Forwards the arguments to llvm::formatv and writes to the stream.
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
size_t EOL()
Output and End of Line character to the stream.
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.
llvm::StringRef GetLaunchWorkingDirectory() const
bool GetDisableSTDIO() const
llvm::StringRef GetArg0() const
void SetRunArguments(const Args &args)
bool GetDisableASLR() const
const ProcessLaunchInfo & GetProcessLaunchInfo() const
bool GetInheritTCC() const
Environment GetEnvironment() const
void SetProcessLaunchInfo(const ProcessLaunchInfo &launch_info)
bool GetDetachOnError() const
void ClearDummySignals(Args &signal_names)
Clear the dummy signals in signal_names from the target, or all signals if signal_names is empty.
BreakpointList & GetBreakpointList(bool internal=false)
const lldb::ProcessSP & GetProcessSP() const
Status Launch(ProcessLaunchInfo &launch_info, Stream *stream)
lldb::ModuleSP GetExecutableModule()
Gets the module for the main executable.
lldb::PlatformSP GetPlatform()
const ArchSpec & GetArchitecture() const
void AddDummySignal(llvm::StringRef name, LazyBool pass, LazyBool print, LazyBool stop)
Add a signal to the Target's list of stored signals/actions.
void PrintDummySignals(Stream &strm, Args &signals)
Print all the signals set in this target.
Status Attach(ProcessAttachInfo &attach_info, Stream *stream)
uint32_t GetSize(bool can_update=true)
lldb::ThreadSP GetThreadAtIndex(uint32_t idx, bool can_update=true)
std::recursive_mutex & GetMutex() const override
A plug-in interface definition class for trace information.
virtual lldb::CommandObjectSP GetProcessTraceStartCommand(CommandInterpreter &interpreter)=0
Get the command handle for the "process trace start" command.
#define LLDB_INVALID_BREAK_ID
#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...
#define LLDB_INVALID_SIGNAL_NUMBER
#define LLDB_INVALID_IMAGE_TOKEN
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
std::vector< OptionArgElement > OptionElementVector
const char * StateAsCString(lldb::StateType state)
Converts a StateType to a C string.
static uint32_t bits(const uint32_t val, const uint32_t msbit, const uint32_t lsbit)
std::string toString(FormatterBytecode::OpCodes op)
std::shared_ptr< lldb_private::Trace > TraceSP
std::shared_ptr< lldb_private::BreakpointSite > BreakpointSiteSP
std::shared_ptr< lldb_private::BreakpointLocation > BreakpointLocationSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ScriptedMetadata > ScriptedMetadataSP
std::shared_ptr< lldb_private::CommandObject > CommandObjectSP
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
std::shared_ptr< lldb_private::Platform > PlatformSP
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
std::shared_ptr< lldb_private::Process > ProcessSP
@ eReturnStatusSuccessContinuingNoResult
@ eReturnStatusSuccessFinishResult
@ eReturnStatusSuccessFinishNoResult
@ eArgTypeUnsignedInteger
std::shared_ptr< lldb_private::StopInfo > StopInfoSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::Module > ModuleSP
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)