Skip to content

Commit b709149

Browse files
committed
[lldb][NFCI] Target::StopHook::GetDescription should take a Stream ref instead of pointer
We always assume that this is valid anyway, might as well take a reference. Differential Revision: https://reviews.llvm.org/D153917
1 parent c9b31da commit b709149

File tree

4 files changed

+40
-40
lines changed

4 files changed

+40
-40
lines changed

lldb/include/lldb/Target/Target.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,8 +1310,8 @@ class Target : public std::enable_shared_from_this<Target>,
13101310

13111311
bool GetAutoContinue() const { return m_auto_continue; }
13121312

1313-
void GetDescription(Stream *s, lldb::DescriptionLevel level) const;
1314-
virtual void GetSubclassDescription(Stream *s,
1313+
void GetDescription(Stream &s, lldb::DescriptionLevel level) const;
1314+
virtual void GetSubclassDescription(Stream &s,
13151315
lldb::DescriptionLevel level) const = 0;
13161316

13171317
protected:
@@ -1334,7 +1334,7 @@ class Target : public std::enable_shared_from_this<Target>,
13341334

13351335
StopHookResult HandleStop(ExecutionContext &exc_ctx,
13361336
lldb::StreamSP output_sp) override;
1337-
void GetSubclassDescription(Stream *s,
1337+
void GetSubclassDescription(Stream &s,
13381338
lldb::DescriptionLevel level) const override;
13391339

13401340
private:
@@ -1356,7 +1356,7 @@ class Target : public std::enable_shared_from_this<Target>,
13561356
Status SetScriptCallback(std::string class_name,
13571357
StructuredData::ObjectSP extra_args_sp);
13581358

1359-
void GetSubclassDescription(Stream *s,
1359+
void GetSubclassDescription(Stream &s,
13601360
lldb::DescriptionLevel level) const override;
13611361

13621362
private:

lldb/source/Commands/CommandCompletions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ void CommandCompletions::StopHookIDs(CommandInterpreter &interpreter,
754754
// neater.
755755
strm.SetIndentLevel(11);
756756
const Target::StopHookSP stophook_sp = target_sp->GetStopHookAtIndex(idx);
757-
stophook_sp->GetDescription(&strm, lldb::eDescriptionLevelInitial);
757+
stophook_sp->GetDescription(strm, lldb::eDescriptionLevelInitial);
758758
request.TryCompleteCurrentArg(std::to_string(stophook_sp->GetID()),
759759
strm.GetString());
760760
}

lldb/source/Commands/CommandObjectTarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5057,7 +5057,7 @@ class CommandObjectTargetStopHookList : public CommandObjectParsed {
50575057
Target::StopHookSP this_hook = target.GetStopHookAtIndex(i);
50585058
if (i > 0)
50595059
result.GetOutputStream().PutCString("\n");
5060-
this_hook->GetDescription(&(result.GetOutputStream()),
5060+
this_hook->GetDescription(result.GetOutputStream(),
50615061
eDescriptionLevelFull);
50625062
}
50635063
}

lldb/source/Target/Target.cpp

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2892,7 +2892,7 @@ bool Target::RunStopHooks() {
28922892

28932893
if (print_hook_header && !any_thread_matched) {
28942894
StreamString s;
2895-
cur_hook_sp->GetDescription(&s, eDescriptionLevelBrief);
2895+
cur_hook_sp->GetDescription(s, eDescriptionLevelBrief);
28962896
if (s.GetSize() != 0)
28972897
output_sp->Printf("\n- Hook %" PRIu64 " (%s)\n", cur_hook_sp->GetID(),
28982898
s.GetData());
@@ -3651,7 +3651,7 @@ bool Target::StopHook::ExecutionContextPasses(const ExecutionContext &exc_ctx) {
36513651
return will_run;
36523652
}
36533653

3654-
void Target::StopHook::GetDescription(Stream *s,
3654+
void Target::StopHook::GetDescription(Stream &s,
36553655
lldb::DescriptionLevel level) const {
36563656

36573657
// For brief descriptions, only print the subclass description:
@@ -3660,55 +3660,55 @@ void Target::StopHook::GetDescription(Stream *s,
36603660
return;
36613661
}
36623662

3663-
unsigned indent_level = s->GetIndentLevel();
3663+
unsigned indent_level = s.GetIndentLevel();
36643664

3665-
s->SetIndentLevel(indent_level + 2);
3665+
s.SetIndentLevel(indent_level + 2);
36663666

3667-
s->Printf("Hook: %" PRIu64 "\n", GetID());
3667+
s.Printf("Hook: %" PRIu64 "\n", GetID());
36683668
if (m_active)
3669-
s->Indent("State: enabled\n");
3669+
s.Indent("State: enabled\n");
36703670
else
3671-
s->Indent("State: disabled\n");
3671+
s.Indent("State: disabled\n");
36723672

36733673
if (m_auto_continue)
3674-
s->Indent("AutoContinue on\n");
3674+
s.Indent("AutoContinue on\n");
36753675

36763676
if (m_specifier_sp) {
3677-
s->Indent();
3678-
s->PutCString("Specifier:\n");
3679-
s->SetIndentLevel(indent_level + 4);
3680-
m_specifier_sp->GetDescription(s, level);
3681-
s->SetIndentLevel(indent_level + 2);
3677+
s.Indent();
3678+
s.PutCString("Specifier:\n");
3679+
s.SetIndentLevel(indent_level + 4);
3680+
m_specifier_sp->GetDescription(&s, level);
3681+
s.SetIndentLevel(indent_level + 2);
36823682
}
36833683

36843684
if (m_thread_spec_up) {
36853685
StreamString tmp;
3686-
s->Indent("Thread:\n");
3686+
s.Indent("Thread:\n");
36873687
m_thread_spec_up->GetDescription(&tmp, level);
3688-
s->SetIndentLevel(indent_level + 4);
3689-
s->Indent(tmp.GetString());
3690-
s->PutCString("\n");
3691-
s->SetIndentLevel(indent_level + 2);
3688+
s.SetIndentLevel(indent_level + 4);
3689+
s.Indent(tmp.GetString());
3690+
s.PutCString("\n");
3691+
s.SetIndentLevel(indent_level + 2);
36923692
}
36933693
GetSubclassDescription(s, level);
36943694
}
36953695

36963696
void Target::StopHookCommandLine::GetSubclassDescription(
3697-
Stream *s, lldb::DescriptionLevel level) const {
3697+
Stream &s, lldb::DescriptionLevel level) const {
36983698
// The brief description just prints the first command.
36993699
if (level == eDescriptionLevelBrief) {
37003700
if (m_commands.GetSize() == 1)
3701-
s->PutCString(m_commands.GetStringAtIndex(0));
3701+
s.PutCString(m_commands.GetStringAtIndex(0));
37023702
return;
37033703
}
3704-
s->Indent("Commands: \n");
3705-
s->SetIndentLevel(s->GetIndentLevel() + 4);
3704+
s.Indent("Commands: \n");
3705+
s.SetIndentLevel(s.GetIndentLevel() + 4);
37063706
uint32_t num_commands = m_commands.GetSize();
37073707
for (uint32_t i = 0; i < num_commands; i++) {
3708-
s->Indent(m_commands.GetStringAtIndex(i));
3709-
s->PutCString("\n");
3708+
s.Indent(m_commands.GetStringAtIndex(i));
3709+
s.PutCString("\n");
37103710
}
3711-
s->SetIndentLevel(s->GetIndentLevel() - 4);
3711+
s.SetIndentLevel(s.GetIndentLevel() - 4);
37123712
}
37133713

37143714
// Target::StopHookCommandLine
@@ -3796,13 +3796,13 @@ Target::StopHookScripted::HandleStop(ExecutionContext &exc_ctx,
37963796
}
37973797

37983798
void Target::StopHookScripted::GetSubclassDescription(
3799-
Stream *s, lldb::DescriptionLevel level) const {
3799+
Stream &s, lldb::DescriptionLevel level) const {
38003800
if (level == eDescriptionLevelBrief) {
3801-
s->PutCString(m_class_name);
3801+
s.PutCString(m_class_name);
38023802
return;
38033803
}
3804-
s->Indent("Class:");
3805-
s->Printf("%s\n", m_class_name.c_str());
3804+
s.Indent("Class:");
3805+
s.Printf("%s\n", m_class_name.c_str());
38063806

38073807
// Now print the extra args:
38083808
// FIXME: We should use StructuredData.GetDescription on the m_extra_args
@@ -3821,20 +3821,20 @@ void Target::StopHookScripted::GetSubclassDescription(
38213821
if (num_keys == 0)
38223822
return;
38233823

3824-
s->Indent("Args:\n");
3825-
s->SetIndentLevel(s->GetIndentLevel() + 4);
3824+
s.Indent("Args:\n");
3825+
s.SetIndentLevel(s.GetIndentLevel() + 4);
38263826

38273827
auto print_one_element = [&s](ConstString key,
38283828
StructuredData::Object *object) {
3829-
s->Indent();
3830-
s->Printf("%s : %s\n", key.GetCString(),
3829+
s.Indent();
3830+
s.Printf("%s : %s\n", key.GetCString(),
38313831
object->GetStringValue().str().c_str());
38323832
return true;
38333833
};
38343834

38353835
as_dict->ForEach(print_one_element);
38363836

3837-
s->SetIndentLevel(s->GetIndentLevel() - 4);
3837+
s.SetIndentLevel(s.GetIndentLevel() - 4);
38383838
}
38393839

38403840
static constexpr OptionEnumValueElement g_dynamic_value_types[] = {

0 commit comments

Comments
 (0)