Skip to content

Commit 7a1c31b

Browse files
author
Mikhail Zakharov
committed
[lldb] Code review follow up
1 parent ad45f5d commit 7a1c31b

File tree

4 files changed

+26
-41
lines changed

4 files changed

+26
-41
lines changed

lldb/source/Commands/CommandObjectProcess.cpp

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,6 +1377,9 @@ class CommandObjectProcessStatus : public CommandObjectParsed {
13771377
case 'v':
13781378
m_verbose = true;
13791379
break;
1380+
case 'd':
1381+
m_dump = true;
1382+
break;
13801383
default:
13811384
llvm_unreachable("Unimplemented option");
13821385
}
@@ -1386,6 +1389,7 @@ class CommandObjectProcessStatus : public CommandObjectParsed {
13861389

13871390
void OptionParsingStarting(ExecutionContext *execution_context) override {
13881391
m_verbose = false;
1392+
m_dump = false;
13891393
}
13901394

13911395
llvm::ArrayRef<OptionDefinition> GetDefinitions() override {
@@ -1394,6 +1398,7 @@ class CommandObjectProcessStatus : public CommandObjectParsed {
13941398

13951399
// Instance variables to hold the values for command options.
13961400
bool m_verbose = false;
1401+
bool m_dump = false;
13971402
};
13981403

13991404
protected:
@@ -1448,6 +1453,14 @@ class CommandObjectProcessStatus : public CommandObjectParsed {
14481453
crash_info_sp->GetDescription(strm);
14491454
}
14501455
}
1456+
1457+
if (m_options.m_dump) {
1458+
StateType state = process->GetState();
1459+
if (state == eStateStopped) {
1460+
ProcessModID process_mod_id = process->GetModID();
1461+
process_mod_id.Dump(result.GetOutputStream());
1462+
}
1463+
}
14511464
}
14521465

14531466
private:
@@ -1827,33 +1840,6 @@ class CommandObjectMultiwordProcessTrace : public CommandObjectMultiword {
18271840
~CommandObjectMultiwordProcessTrace() override = default;
18281841
};
18291842

1830-
// CommandObjectProcessDumpModificationId
1831-
class CommandObjectProcessDumpModificationId : public CommandObjectParsed {
1832-
public:
1833-
CommandObjectProcessDumpModificationId(CommandInterpreter &interpreter)
1834-
: CommandObjectParsed(interpreter, "process dump-modification-id",
1835-
"Dump the state of the ProcessModID. Intended to "
1836-
"be used for debugging LLDB itself.",
1837-
"process dump-modification-id",
1838-
eCommandRequiresProcess) {}
1839-
1840-
~CommandObjectProcessDumpModificationId() override = default;
1841-
1842-
protected:
1843-
void DoExecute(Args &command, CommandReturnObject &result) override {
1844-
Process *process = m_exe_ctx.GetProcessPtr();
1845-
StateType state = process->GetState();
1846-
if (state != eStateStopped) {
1847-
result.SetStatus(eReturnStatusFailed);
1848-
return;
1849-
}
1850-
1851-
ProcessModID process_mod_id = process->GetModID();
1852-
process_mod_id.Dump(result.GetOutputStream());
1853-
result.SetStatus(eReturnStatusSuccessFinishResult);
1854-
}
1855-
};
1856-
18571843
// CommandObjectMultiwordProcess
18581844

18591845
CommandObjectMultiwordProcess::CommandObjectMultiwordProcess(
@@ -1893,9 +1879,6 @@ CommandObjectMultiwordProcess::CommandObjectMultiwordProcess(
18931879
LoadSubCommand(
18941880
"trace",
18951881
CommandObjectSP(new CommandObjectMultiwordProcessTrace(interpreter)));
1896-
LoadSubCommand(
1897-
"dump-modification-id",
1898-
CommandObjectSP(new CommandObjectProcessDumpModificationId(interpreter)));
18991882
}
19001883

19011884
CommandObjectMultiwordProcess::~CommandObjectMultiwordProcess() = default;

lldb/source/Commands/Options.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,8 @@ let Command = "process handle" in {
784784
let Command = "process status" in {
785785
def process_status_verbose : Option<"verbose", "v">, Group<1>,
786786
Desc<"Show verbose process status including extended crash information.">;
787+
def process_status_dump : Option<"dump-modification-id", "d">, Group<1>,
788+
Desc<"Dump the state of the ProcessModID of the stopped process.">;
787789
}
788790

789791
let Command = "process save_core" in {

lldb/source/Target/TargetProperties.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ let Definition = "process" in {
298298
Desc<"Debugger's behavior upon fork or vfork.">;
299299
def TrackMemoryCacheChanges: Property<"track-memory-cache-changes", "Boolean">,
300300
DefaultTrue,
301-
Desc<"If true, memory cache modifications (which happen often during expressions evaluation) will bump process state ID (and invalidate all synthetic children). Disabling this option helps to avoid synthetic children reevaluation when pretty printers heavily use expressions, but convenience variables won't reevaluate synthetic children automatically.">;
301+
Desc<"If true, memory cache modifications (which happen often during expressions evaluation) will bump process state ID (and invalidate all synthetic children). Disabling this option helps to avoid synthetic children reevaluation when pretty printers heavily use expressions. The downside of disabled setting is that convenience variables won't reevaluate synthetic children automatically.">;
302302
}
303303

304304
let Definition = "platform" in {

lldb/test/Shell/Expr/TestProcessModificationIdOnExpr.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
// RUN: %lldb %t \
88
// RUN: -o "settings set target.process.track-memory-cache-changes false" \
99
// RUN: -o "run" \
10-
// RUN: -o "process dump-modification-id" \
10+
// RUN: -o "process status -d" \
1111
// RUN: -o "expr x.i != 42" \
12-
// RUN: -o "process dump-modification-id" \
12+
// RUN: -o "process status -d" \
1313
// RUN: -o "expr x.get()" \
14-
// RUN: -o "process dump-modification-id" \
14+
// RUN: -o "process status -d" \
1515
// RUN: -o "expr x.i = 10" \
16-
// RUN: -o "process dump-modification-id" \
16+
// RUN: -o "process status -d" \
1717
// RUN: -o "continue" \
18-
// RUN: -o "process dump-modification-id" \
18+
// RUN: -o "process status -d" \
1919
// RUN: -o "exit" | FileCheck %s -dump-input=fail
2020

2121
class X {
@@ -34,34 +34,34 @@ int main() {
3434
return 0;
3535
}
3636

37-
// CHECK-LABEL: process dump-modification-id
37+
// CHECK-LABEL: process status -d
3838
// CHECK: m_stop_id: 2
3939
// CHECK: m_memory_id: 0
4040

4141
// CHECK-LABEL: expr x.i != 42
4242
// IDs are not changed when executing simple expressions
4343

44-
// CHECK-LABEL: process dump-modification-id
44+
// CHECK-LABEL: process status -d
4545
// CHECK: m_stop_id: 2
4646
// CHECK: m_memory_id: 0
4747

4848
// CHECK-LABEL: expr x.get()
4949
// Expression causes ID to be bumped because LLDB has to execute function
5050

51-
// CHECK-LABEL: process dump-modification-id
51+
// CHECK-LABEL: process status -d
5252
// CHECK: m_stop_id: 3
5353
// CHECK: m_memory_id: 1
5454

5555
// CHECK-LABEL: expr x.i = 10
5656
// Expression causes MemoryID to be bumped because LLDB writes to non-cache memory
5757

58-
// CHECK-LABEL: process dump-modification-id
58+
// CHECK-LABEL: process status -d
5959
// CHECK: m_stop_id: 3
6060
// CHECK: m_memory_id: 2
6161

6262
// CHECK-LABEL: continue
6363
// Continue causes StopID to be bumped because process is resumed
6464

65-
// CHECK-LABEL: process dump-modification-id
65+
// CHECK-LABEL: process status -d
6666
// CHECK: m_stop_id: 4
6767
// CHECK: m_memory_id: 2

0 commit comments

Comments
 (0)