aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectProcess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Commands/CommandObjectProcess.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectProcess.cpp77
1 files changed, 76 insertions, 1 deletions
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp
index 0145122..4ee085e 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -1201,6 +1201,8 @@ protected:
// CommandObjectProcessStatus
#pragma mark CommandObjectProcessStatus
+#define LLDB_OPTIONS_process_status
+#include "CommandOptions.inc"
class CommandObjectProcessStatus : public CommandObjectParsed {
public:
@@ -1209,13 +1211,57 @@ public:
interpreter, "process status",
"Show status and stop location for the current target process.",
"process status",
- eCommandRequiresProcess | eCommandTryTargetAPILock) {}
+ eCommandRequiresProcess | eCommandTryTargetAPILock),
+ m_options() {}
~CommandObjectProcessStatus() override = default;
+ Options *GetOptions() override { return &m_options; }
+
+ class CommandOptions : public Options {
+ public:
+ CommandOptions() : Options(), m_verbose(false) {}
+
+ ~CommandOptions() override = default;
+
+ Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg,
+ ExecutionContext *execution_context) override {
+ const int short_option = m_getopt_table[option_idx].val;
+
+ switch (short_option) {
+ case 'v':
+ m_verbose = true;
+ break;
+ default:
+ llvm_unreachable("Unimplemented option");
+ }
+
+ return {};
+ }
+
+ void OptionParsingStarting(ExecutionContext *execution_context) override {
+ m_verbose = false;
+ }
+
+ llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
+ return llvm::makeArrayRef(g_process_status_options);
+ }
+
+ // Instance variables to hold the values for command options.
+ bool m_verbose;
+ };
+
+protected:
bool DoExecute(Args &command, CommandReturnObject &result) override {
Stream &strm = result.GetOutputStream();
result.SetStatus(eReturnStatusSuccessFinishNoResult);
+
+ if (command.GetArgumentCount()) {
+ result.AppendError("'process status' takes no arguments");
+ result.SetStatus(eReturnStatusFailed);
+ return result.Succeeded();
+ }
+
// No need to check "process" for validity as eCommandRequiresProcess
// ensures it is valid
Process *process = m_exe_ctx.GetProcessPtr();
@@ -1227,8 +1273,37 @@ public:
process->GetStatus(strm);
process->GetThreadStatus(strm, only_threads_with_stop_reason, start_frame,
num_frames, num_frames_with_source, stop_format);
+
+ if (m_options.m_verbose) {
+ PlatformSP platform_sp = process->GetTarget().GetPlatform();
+ if (!platform_sp) {
+ result.AppendError("Couldn'retrieve the target's platform");
+ result.SetStatus(eReturnStatusFailed);
+ return result.Succeeded();
+ }
+
+ auto expected_crash_info =
+ platform_sp->FetchExtendedCrashInformation(process->GetTarget());
+
+ if (!expected_crash_info) {
+ result.AppendError(llvm::toString(expected_crash_info.takeError()));
+ result.SetStatus(eReturnStatusFailed);
+ return result.Succeeded();
+ }
+
+ StructuredData::DictionarySP crash_info_sp = *expected_crash_info;
+
+ if (crash_info_sp) {
+ strm.PutCString("Extended Crash Information:\n");
+ crash_info_sp->Dump(strm);
+ }
+ }
+
return result.Succeeded();
}
+
+private:
+ CommandOptions m_options;
};
// CommandObjectProcessHandle