[Lldb-commits] [PATCH] D158209: [lldb] Change UnixSignals::GetSignalAsCString to GetSignalAsStringRef
This revision was automatically updated to reflect the committed changes. Closed by commit rG58fe7b751dc4: [lldb] Change UnixSignals::GetSignalAsCString to GetSignalAsStringRef (authored by bulbazord). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D158209/new/ https://reviews.llvm.org/D158209 Files: lldb/include/lldb/Target/UnixSignals.h lldb/source/API/SBUnixSignals.cpp lldb/source/Commands/CommandObjectProcess.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Target/Process.cpp lldb/source/Target/StopInfo.cpp lldb/source/Target/UnixSignals.cpp lldb/unittests/Signals/UnixSignalsTest.cpp Index: lldb/unittests/Signals/UnixSignalsTest.cpp === --- lldb/unittests/Signals/UnixSignalsTest.cpp +++ lldb/unittests/Signals/UnixSignalsTest.cpp @@ -84,7 +84,7 @@ bool should_suppress = false, should_stop = false, should_notify = false; int32_t signo = 4; - std::string name = + llvm::StringRef name = signals.GetSignalInfo(signo, should_suppress, should_stop, should_notify); EXPECT_EQ("SIG4", name); EXPECT_EQ(true, should_suppress); @@ -94,15 +94,14 @@ EXPECT_EQ(true, signals.GetShouldSuppress(signo)); EXPECT_EQ(false, signals.GetShouldStop(signo)); EXPECT_EQ(true, signals.GetShouldNotify(signo)); - EXPECT_EQ(name, signals.GetSignalAsCString(signo)); + EXPECT_EQ(name, signals.GetSignalAsStringRef(signo)); } -TEST(UnixSignalsTest, GetAsCString) { +TEST(UnixSignalsTest, GetAsStringRef) { TestSignals signals; - ASSERT_EQ(nullptr, signals.GetSignalAsCString(100)); - std::string name = signals.GetSignalAsCString(16); - ASSERT_EQ("SIG16", name); + ASSERT_EQ(llvm::StringRef(), signals.GetSignalAsStringRef(100)); + ASSERT_EQ("SIG16", signals.GetSignalAsStringRef(16)); } TEST(UnixSignalsTest, GetAsString) { Index: lldb/source/Target/UnixSignals.cpp === --- lldb/source/Target/UnixSignals.cpp +++ lldb/source/Target/UnixSignals.cpp @@ -131,12 +131,11 @@ ++m_version; } -const char *UnixSignals::GetSignalAsCString(int signo) const { - collection::const_iterator pos = m_signals.find(signo); +llvm::StringRef UnixSignals::GetSignalAsStringRef(int32_t signo) const { + const auto pos = m_signals.find(signo); if (pos == m_signals.end()) -return nullptr; - else -return pos->second.m_name.GetCString(); +return {}; + return pos->second.m_name.GetStringRef(); } std::string Index: lldb/source/Target/StopInfo.cpp === --- lldb/source/Target/StopInfo.cpp +++ lldb/source/Target/StopInfo.cpp @@ -1067,9 +1067,9 @@ thread_sp->GetProcess()->GetUnixSignals()->GetShouldNotify(m_value); if (should_notify) { StreamString strm; -strm.Printf( -"thread %d received signal: %s", thread_sp->GetIndexID(), -thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsCString( +strm.Format( +"thread {0:d} received signal: {1}", thread_sp->GetIndexID(), +thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsStringRef( m_value)); Process::ProcessEventData::AddRestartedReason(event_ptr, strm.GetData()); Index: lldb/source/Target/Process.cpp === --- lldb/source/Target/Process.cpp +++ lldb/source/Target/Process.cpp @@ -1125,11 +1125,9 @@ if (target_sp) { ProcessSP process_sp(target_sp->GetProcessSP()); if (process_sp) { -const char *signal_cstr = nullptr; -if (signo) - signal_cstr = process_sp->GetUnixSignals()->GetSignalAsCString(signo); - -process_sp->SetExitStatus(exit_status, signal_cstr); +llvm::StringRef signal_str = +process_sp->GetUnixSignals()->GetSignalAsStringRef(signo); +process_sp->SetExitStatus(exit_status, signal_str); } } return true; Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp === --- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -3384,10 +3384,10 @@ stream.Format(DEBUGSERVER_BASENAME " died with an exit status of {0:x8}", exit_status); else { - const char *signal_name = - process_sp->GetUnixSignals()->GetSignalAsCString(signo); + llvm::StringRef signal_name = + process_sp->GetUnixSignals()->GetSignalAsStringRef(signo); const char *format_str = DEBUGSERVER_BASENAME " died with signal {0}"; - if (signal_name) + if (!signal_name.empty())
[Lldb-commits] [PATCH] D158209: [lldb] Change UnixSignals::GetSignalAsCString to GetSignalAsStringRef
DavidSpickett accepted this revision. DavidSpickett added a comment. This revision is now accepted and ready to land. LGTM. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D158209/new/ https://reviews.llvm.org/D158209 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D158209: [lldb] Change UnixSignals::GetSignalAsCString to GetSignalAsStringRef
bulbazord created this revision. bulbazord added reviewers: JDevlieghere, mib, jasonmolenda, jingham. Herald added a project: All. bulbazord requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits. This is in preparation to remove the uses of ConstString from UnixSignals. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D158209 Files: lldb/include/lldb/Target/UnixSignals.h lldb/source/API/SBUnixSignals.cpp lldb/source/Commands/CommandObjectProcess.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Target/Process.cpp lldb/source/Target/StopInfo.cpp lldb/source/Target/UnixSignals.cpp lldb/unittests/Signals/UnixSignalsTest.cpp Index: lldb/unittests/Signals/UnixSignalsTest.cpp === --- lldb/unittests/Signals/UnixSignalsTest.cpp +++ lldb/unittests/Signals/UnixSignalsTest.cpp @@ -84,7 +84,7 @@ bool should_suppress = false, should_stop = false, should_notify = false; int32_t signo = 4; - std::string name = + llvm::StringRef name = signals.GetSignalInfo(signo, should_suppress, should_stop, should_notify); EXPECT_EQ("SIG4", name); EXPECT_EQ(true, should_suppress); @@ -94,15 +94,14 @@ EXPECT_EQ(true, signals.GetShouldSuppress(signo)); EXPECT_EQ(false, signals.GetShouldStop(signo)); EXPECT_EQ(true, signals.GetShouldNotify(signo)); - EXPECT_EQ(name, signals.GetSignalAsCString(signo)); + EXPECT_EQ(name, signals.GetSignalAsStringRef(signo)); } -TEST(UnixSignalsTest, GetAsCString) { +TEST(UnixSignalsTest, GetAsStringRef) { TestSignals signals; - ASSERT_EQ(nullptr, signals.GetSignalAsCString(100)); - std::string name = signals.GetSignalAsCString(16); - ASSERT_EQ("SIG16", name); + ASSERT_EQ(llvm::StringRef(), signals.GetSignalAsStringRef(100)); + ASSERT_EQ("SIG16", signals.GetSignalAsStringRef(16)); } TEST(UnixSignalsTest, GetAsString) { Index: lldb/source/Target/UnixSignals.cpp === --- lldb/source/Target/UnixSignals.cpp +++ lldb/source/Target/UnixSignals.cpp @@ -131,12 +131,11 @@ ++m_version; } -const char *UnixSignals::GetSignalAsCString(int signo) const { - collection::const_iterator pos = m_signals.find(signo); +llvm::StringRef UnixSignals::GetSignalAsStringRef(int32_t signo) const { + const auto pos = m_signals.find(signo); if (pos == m_signals.end()) -return nullptr; - else -return pos->second.m_name.GetCString(); +return {}; + return pos->second.m_name.GetStringRef(); } std::string Index: lldb/source/Target/StopInfo.cpp === --- lldb/source/Target/StopInfo.cpp +++ lldb/source/Target/StopInfo.cpp @@ -1067,9 +1067,9 @@ thread_sp->GetProcess()->GetUnixSignals()->GetShouldNotify(m_value); if (should_notify) { StreamString strm; -strm.Printf( -"thread %d received signal: %s", thread_sp->GetIndexID(), -thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsCString( +strm.Format( +"thread {0:d} received signal: {1}", thread_sp->GetIndexID(), +thread_sp->GetProcess()->GetUnixSignals()->GetSignalAsStringRef( m_value)); Process::ProcessEventData::AddRestartedReason(event_ptr, strm.GetData()); Index: lldb/source/Target/Process.cpp === --- lldb/source/Target/Process.cpp +++ lldb/source/Target/Process.cpp @@ -1124,11 +1124,9 @@ if (target_sp) { ProcessSP process_sp(target_sp->GetProcessSP()); if (process_sp) { -const char *signal_cstr = nullptr; -if (signo) - signal_cstr = process_sp->GetUnixSignals()->GetSignalAsCString(signo); - -process_sp->SetExitStatus(exit_status, signal_cstr); +llvm::StringRef signal_str = +process_sp->GetUnixSignals()->GetSignalAsStringRef(signo); +process_sp->SetExitStatus(exit_status, signal_str); } } return true; Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp === --- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -3384,10 +3384,10 @@ stream.Format(DEBUGSERVER_BASENAME " died with an exit status of {0:x8}", exit_status); else { - const char *signal_name = - process_sp->GetUnixSignals()->GetSignalAsCString(signo); + llvm::StringRef signal_name = + process_sp->GetUnixSignals()->GetSignalAsStringRef(signo); const char *format_str = DEBUGSERVER_BASENAME " died with signal {0}"; - if