Skip to content

Commit 3e60bdf

Browse files
committed
[lldb] Simplify printing of stop hooks
Simplify printing of stop hooks using the new IndentScope.
1 parent dc15f12 commit 3e60bdf

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

lldb/source/Target/Target.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3961,9 +3961,7 @@ void Target::StopHook::GetDescription(Stream &s,
39613961
return;
39623962
}
39633963

3964-
unsigned indent_level = s.GetIndentLevel();
3965-
3966-
s.SetIndentLevel(indent_level + 2);
3964+
auto indent_scope = s.MakeIndentScope();
39673965

39683966
s.Printf("Hook: %" PRIu64 "\n", GetID());
39693967
if (m_active)
@@ -3977,22 +3975,19 @@ void Target::StopHook::GetDescription(Stream &s,
39773975
if (m_specifier_sp) {
39783976
s.Indent();
39793977
s.PutCString("Specifier:\n");
3980-
s.SetIndentLevel(indent_level + 4);
3978+
auto indent_scope = s.MakeIndentScope();
39813979
m_specifier_sp->GetDescription(&s, level);
3982-
s.SetIndentLevel(indent_level + 2);
39833980
}
39843981

39853982
if (m_thread_spec_up) {
39863983
StreamString tmp;
39873984
s.Indent("Thread:\n");
39883985
m_thread_spec_up->GetDescription(&tmp, level);
3989-
s.SetIndentLevel(indent_level + 4);
3986+
auto indent_scope = s.MakeIndentScope();
39903987
s.Indent(tmp.GetString());
39913988
s.PutCString("\n");
3992-
s.SetIndentLevel(indent_level + 2);
39933989
}
39943990
GetSubclassDescription(s, level);
3995-
s.SetIndentLevel(indent_level);
39963991
}
39973992

39983993
void Target::StopHookCommandLine::GetSubclassDescription(
@@ -4004,13 +3999,12 @@ void Target::StopHookCommandLine::GetSubclassDescription(
40043999
return;
40054000
}
40064001
s.Indent("Commands:\n");
4007-
s.SetIndentLevel(s.GetIndentLevel() + 4);
4002+
auto indent_scope = s.MakeIndentScope(4);
40084003
uint32_t num_commands = m_commands.GetSize();
40094004
for (uint32_t i = 0; i < num_commands; i++) {
40104005
s.Indent(m_commands.GetStringAtIndex(i));
40114006
s.PutCString("\n");
40124007
}
4013-
s.SetIndentLevel(s.GetIndentLevel() - 4);
40144008
}
40154009

40164010
// Target::StopHookCommandLine
@@ -4145,7 +4139,7 @@ void Target::StopHookScripted::GetSubclassDescription(
41454139
return;
41464140

41474141
s.Indent("Args:\n");
4148-
s.SetIndentLevel(s.GetIndentLevel() + 4);
4142+
auto indent_scope = s.MakeIndentScope(4);
41494143

41504144
auto print_one_element = [&s](llvm::StringRef key,
41514145
StructuredData::Object *object) {
@@ -4155,8 +4149,6 @@ void Target::StopHookScripted::GetSubclassDescription(
41554149
};
41564150

41574151
as_dict->ForEach(print_one_element);
4158-
4159-
s.SetIndentLevel(s.GetIndentLevel() - 4);
41604152
}
41614153

41624154
static constexpr OptionEnumValueElement g_dynamic_value_types[] = {

0 commit comments

Comments
 (0)