From c156427ded1dfa7686c90cc56ad16013a079a742 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Wed, 16 Nov 2016 21:15:24 +0000 Subject: [PATCH] Don't allow direct access to StreamString's internal buffer. This is a large API change that removes the two functions from StreamString that return a std::string& and a const std::string&, and instead provide one function which returns a StringRef. Direct access to the underlying buffer violates the concept of a "stream" which is intended to provide forward only access, and makes porting to llvm::raw_ostream more difficult in the future. Differential Revision: https://reviews.llvm.org/D26698 llvm-svn: 287152 --- lldb/include/lldb/Core/Error.h | 2 +- lldb/include/lldb/Core/Log.h | 1 + lldb/include/lldb/Core/StreamGDBRemote.h | 1 + lldb/include/lldb/Core/StreamString.h | 6 +- lldb/include/lldb/DataFormatters/FormatClasses.h | 7 +- lldb/include/lldb/Host/Host.h | 1 + .../include/lldb/Interpreter/CommandReturnObject.h | 17 +++-- lldb/include/lldb/Target/Process.h | 1 + lldb/packages/Python/lldbsuite/test/lldbtest.py | 2 + lldb/source/API/SBCommandReturnObject.cpp | 19 +++--- lldb/source/API/SBFrame.cpp | 2 +- lldb/source/API/SBStream.cpp | 11 ++-- lldb/source/API/SBTarget.cpp | 2 +- lldb/source/Commands/CommandObjectBreakpoint.cpp | 4 +- lldb/source/Commands/CommandObjectCommands.cpp | 12 ++-- lldb/source/Commands/CommandObjectHelp.cpp | 6 +- lldb/source/Commands/CommandObjectMemory.cpp | 4 +- lldb/source/Commands/CommandObjectMultiword.cpp | 2 +- lldb/source/Commands/CommandObjectProcess.cpp | 12 ++-- lldb/source/Commands/CommandObjectQuit.cpp | 2 +- lldb/source/Commands/CommandObjectTarget.cpp | 10 +-- lldb/source/Commands/CommandObjectThread.cpp | 12 ++-- lldb/source/Commands/CommandObjectType.cpp | 6 +- lldb/source/Core/Address.cpp | 2 +- lldb/source/Core/DataExtractor.cpp | 6 +- lldb/source/Core/Debugger.cpp | 2 +- lldb/source/Core/Disassembler.cpp | 2 +- lldb/source/Core/EmulateInstruction.cpp | 4 +- lldb/source/Core/Error.cpp | 13 ++-- lldb/source/Core/Event.cpp | 2 +- lldb/source/Core/FormatEntity.cpp | 27 ++++---- lldb/source/Core/IOHandler.cpp | 18 ++--- lldb/source/Core/Log.cpp | 1 + lldb/source/Core/Module.cpp | 12 ++-- lldb/source/Core/RegisterValue.cpp | 10 +-- lldb/source/Core/StreamString.cpp | 6 +- lldb/source/Core/StringList.cpp | 2 +- lldb/source/Core/StructuredData.cpp | 5 +- lldb/source/Core/ValueObject.cpp | 52 +++++++-------- lldb/source/DataFormatters/FormatManager.cpp | 5 +- lldb/source/DataFormatters/TypeCategory.cpp | 7 +- lldb/source/DataFormatters/TypeFormat.cpp | 9 +-- lldb/source/DataFormatters/TypeSummary.cpp | 4 +- lldb/source/DataFormatters/ValueObjectPrinter.cpp | 13 ++-- lldb/source/DataFormatters/VectorType.cpp | 2 +- lldb/source/Expression/IRExecutionUnit.cpp | 2 +- lldb/source/Expression/LLVMUserExpression.cpp | 2 +- lldb/source/Expression/Materializer.cpp | 10 +-- lldb/source/Host/macosx/Host.mm | 11 ++-- .../Host/posix/ConnectionFileDescriptorPosix.cpp | 2 +- lldb/source/Host/windows/Host.cpp | 5 +- lldb/source/Interpreter/Args.cpp | 13 ++-- lldb/source/Interpreter/CommandAlias.cpp | 2 +- lldb/source/Interpreter/CommandInterpreter.cpp | 77 ++++++++++++---------- lldb/source/Interpreter/CommandObject.cpp | 24 +++---- lldb/source/Interpreter/CommandReturnObject.cpp | 4 +- lldb/source/Interpreter/OptionValueEnumeration.cpp | 2 +- lldb/source/Interpreter/OptionValueLanguage.cpp | 2 +- lldb/source/Interpreter/Options.cpp | 4 +- lldb/source/Interpreter/Property.cpp | 10 +-- .../Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp | 2 +- .../Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp | 2 +- lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp | 2 +- .../Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp | 2 +- lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp | 2 +- .../Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp | 2 +- .../Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp | 2 +- .../Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp | 2 +- .../Disassembler/llvm/DisassemblerLLVMC.cpp | 8 +-- .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp | 2 +- .../ExpressionParser/Clang/ClangASTSource.cpp | 11 ++-- .../Clang/ClangExpressionParser.cpp | 4 +- .../Plugins/Instruction/ARM/EmulationStateARM.cpp | 4 +- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp | 4 +- .../Language/CPlusPlus/LibCxxInitializerList.cpp | 2 +- .../Plugins/Language/CPlusPlus/LibCxxList.cpp | 5 +- .../Plugins/Language/CPlusPlus/LibCxxMap.cpp | 5 +- .../Language/CPlusPlus/LibCxxUnorderedMap.cpp | 2 +- .../Plugins/Language/CPlusPlus/LibCxxVector.cpp | 2 +- .../Plugins/Language/CPlusPlus/LibStdcppTuple.cpp | 2 +- .../Plugins/Language/Go/GoFormatterFunctions.cpp | 2 +- .../Language/Java/JavaFormatterFunctions.cpp | 2 +- lldb/source/Plugins/Language/ObjC/NSArray.cpp | 4 +- lldb/source/Plugins/Language/ObjC/NSDictionary.cpp | 4 +- lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp | 4 +- lldb/source/Plugins/Language/ObjC/NSSet.cpp | 4 +- lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp | 12 ++-- .../AppleObjCTypeEncodingParser.cpp | 2 +- .../RenderScriptRuntime/RenderScriptRuntime.cpp | 2 +- .../MemoryHistory/asan/MemoryHistoryASan.cpp | 2 +- .../Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp | 3 +- .../Python/OperatingSystemPython.cpp | 5 +- lldb/source/Plugins/Platform/Android/AdbClient.cpp | 2 +- .../Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp | 2 +- .../Plugins/Platform/Kalimba/PlatformKalimba.cpp | 2 +- .../Plugins/Platform/Linux/PlatformLinux.cpp | 6 +- .../Platform/MacOSX/PlatformAppleTVSimulator.cpp | 2 +- .../MacOSX/PlatformAppleWatchSimulator.cpp | 2 +- .../Plugins/Platform/MacOSX/PlatformDarwin.cpp | 8 +-- .../Plugins/Platform/MacOSX/PlatformMacOSX.cpp | 4 +- .../Platform/MacOSX/PlatformRemoteAppleTV.cpp | 2 +- .../Platform/MacOSX/PlatformRemoteAppleWatch.cpp | 2 +- .../Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp | 2 +- .../Platform/MacOSX/PlatformiOSSimulator.cpp | 2 +- .../Plugins/Platform/NetBSD/PlatformNetBSD.cpp | 2 +- .../Plugins/Platform/POSIX/PlatformPOSIX.cpp | 2 +- .../Plugins/Platform/Windows/PlatformWindows.cpp | 4 +- .../gdb-server/PlatformRemoteGDBServer.cpp | 4 +- .../Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp | 2 +- .../Process/Utility/RegisterContextLLDB.cpp | 6 +- .../Process/Utility/StopInfoMachException.cpp | 2 +- .../Process/gdb-remote/GDBRemoteCommunication.cpp | 10 +-- .../gdb-remote/GDBRemoteCommunicationClient.cpp | 26 ++++---- .../GDBRemoteCommunicationServerCommon.cpp | 3 +- .../GDBRemoteCommunicationServerPlatform.cpp | 3 +- .../Process/gdb-remote/ProcessGDBRemote.cpp | 17 +++-- .../Python/ScriptInterpreterPython.cpp | 6 +- .../DarwinLog/StructuredDataDarwinLog.cpp | 14 ++-- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 4 +- .../Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp | 2 +- .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 2 +- .../InstEmulation/UnwindAssemblyInstEmulation.cpp | 15 ++--- lldb/source/Symbol/ObjectFile.cpp | 2 +- lldb/source/Target/Process.cpp | 6 +- lldb/source/Target/StackFrame.cpp | 58 ++++++++-------- lldb/source/Target/StopInfo.cpp | 10 +-- lldb/source/Target/Target.cpp | 2 +- lldb/source/Target/TargetList.cpp | 5 +- lldb/source/Target/Thread.cpp | 3 +- lldb/source/Target/ThreadPlanCallFunction.cpp | 4 +- .../source/Target/ThreadPlanCallUserExpression.cpp | 3 +- lldb/source/Target/ThreadPlanStepOverRange.cpp | 2 +- lldb/tools/argdumper/argdumper.cpp | 3 +- .../Python/PythonDataObjectsTests.cpp | 14 ++-- 134 files changed, 448 insertions(+), 453 deletions(-) diff --git a/lldb/include/lldb/Core/Error.h b/lldb/include/lldb/Core/Error.h index f20da38..40f9872 100644 --- a/lldb/include/lldb/Core/Error.h +++ b/lldb/include/lldb/Core/Error.h @@ -245,7 +245,7 @@ public: /// @param err_str /// The new custom error string to copy and cache. //------------------------------------------------------------------ - void SetErrorString(const char *err_str); + void SetErrorString(llvm::StringRef err_str); //------------------------------------------------------------------ /// Set the current error string to a formatted error string. diff --git a/lldb/include/lldb/Core/Log.h b/lldb/include/lldb/Core/Log.h index 7724743..c1abb4e 100644 --- a/lldb/include/lldb/Core/Log.h +++ b/lldb/include/lldb/Core/Log.h @@ -105,6 +105,7 @@ public: virtual ~Log(); virtual void PutCString(const char *cstr); + virtual void PutString(llvm::StringRef str); // CLEANUP: Add llvm::raw_ostream &Stream() function. virtual void Printf(const char *format, ...) diff --git a/lldb/include/lldb/Core/StreamGDBRemote.h b/lldb/include/lldb/Core/StreamGDBRemote.h index 78b7d94..150b301 100644 --- a/lldb/include/lldb/Core/StreamGDBRemote.h +++ b/lldb/include/lldb/Core/StreamGDBRemote.h @@ -42,6 +42,7 @@ public: /// @return /// Number of bytes written. //------------------------------------------------------------------ + // TODO: Convert this function to take ArrayRef int PutEscapedBytes(const void *s, size_t src_len); }; diff --git a/lldb/include/lldb/Core/StreamString.h b/lldb/include/lldb/Core/StreamString.h index a074773..88501a1 100644 --- a/lldb/include/lldb/Core/StreamString.h +++ b/lldb/include/lldb/Core/StreamString.h @@ -32,15 +32,13 @@ public: bool Empty() const; - const char *GetData() const; - size_t GetSize() const; size_t GetSizeOfLastLine() const; - std::string &GetString(); + llvm::StringRef GetString() const; - const std::string &GetString() const; + const char *GetData() const { return m_packet.c_str(); } void FillLastLineToColumn(uint32_t column, char fill_char); diff --git a/lldb/include/lldb/DataFormatters/FormatClasses.h b/lldb/include/lldb/DataFormatters/FormatClasses.h index 304de4a..c559c21 100644 --- a/lldb/include/lldb/DataFormatters/FormatClasses.h +++ b/lldb/include/lldb/DataFormatters/FormatClasses.h @@ -117,17 +117,16 @@ class TypeNameSpecifierImpl { public: TypeNameSpecifierImpl() : m_is_regex(false), m_type() {} - TypeNameSpecifierImpl(const char *name, bool is_regex) + TypeNameSpecifierImpl(llvm::StringRef name, bool is_regex) : m_is_regex(is_regex), m_type() { - if (name) - m_type.m_type_name.assign(name); + m_type.m_type_name = name; } // if constructing with a given type, is_regex cannot be true since we are // giving an exact type to match TypeNameSpecifierImpl(lldb::TypeSP type) : m_is_regex(false), m_type() { if (type) { - m_type.m_type_name.assign(type->GetName().GetCString()); + m_type.m_type_name = type->GetName().GetStringRef(); m_type.m_type_pair.SetType(type); } } diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index f0a73a3e..8af5f32 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -240,6 +240,7 @@ public: //------------------------------------------------------------------ static Error ShellExpandArguments(ProcessLaunchInfo &launch_info); + // TODO: Convert this function to take a StringRef. static Error RunShellCommand( const char *command, // Shouldn't be NULL const FileSpec &working_dir, // Pass empty FileSpec to use the current diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h b/lldb/include/lldb/Interpreter/CommandReturnObject.h index d243faf..6cb05f4 100644 --- a/lldb/include/lldb/Interpreter/CommandReturnObject.h +++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h @@ -20,6 +20,10 @@ #include "lldb/Core/StreamTee.h" #include "lldb/lldb-private.h" +#include "llvm/ADT/StringRef.h" + +#include + namespace lldb_private { class CommandReturnObject { @@ -28,19 +32,18 @@ public: ~CommandReturnObject(); - const char *GetOutputData() { + llvm::StringRef GetOutputData() { lldb::StreamSP stream_sp(m_out_stream.GetStreamAtIndex(eStreamStringIndex)); if (stream_sp) - return static_cast(stream_sp.get())->GetData(); - return ""; + return static_pointer_cast(stream_sp)->GetString(); + return llvm::StringRef(); } - const char *GetErrorData() { + llvm::StringRef GetErrorData() { lldb::StreamSP stream_sp(m_err_stream.GetStreamAtIndex(eStreamStringIndex)); if (stream_sp) - return static_cast(stream_sp.get())->GetData(); - else - return ""; + return static_pointer_cast(stream_sp)->GetString(); + return llvm::StringRef(); } Stream &GetOutputStream() { diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 0f06ca7..55c0835 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1918,6 +1918,7 @@ public: /// @return /// The number of bytes that were actually written. //------------------------------------------------------------------ + // TODO: change this to take an ArrayRef size_t WriteMemory(lldb::addr_t vm_addr, const void *buf, size_t size, Error &error); diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index cde8e91..ba41d5d 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -2195,6 +2195,8 @@ class TestBase(Base): with recording(self, trace) as sbuf: print("looking at:", output, file=sbuf) + if output is None: + output = "" # The heading says either "Expecting" or "Not expecting". heading = "Expecting" if matching else "Not expecting" diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index 51e6781..41d5147 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -59,12 +59,14 @@ const char *SBCommandReturnObject::GetOutput() { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (m_opaque_ap) { + llvm::StringRef output = m_opaque_ap->GetOutputData(); + ConstString result(output.empty() ? llvm::StringRef("") : output); + if (log) log->Printf("SBCommandReturnObject(%p)::GetOutput () => \"%s\"", - static_cast(m_opaque_ap.get()), - m_opaque_ap->GetOutputData()); + static_cast(m_opaque_ap.get()), result.AsCString()); - return m_opaque_ap->GetOutputData(); + return result.AsCString(); } if (log) @@ -78,12 +80,13 @@ const char *SBCommandReturnObject::GetError() { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (m_opaque_ap) { + llvm::StringRef output = m_opaque_ap->GetErrorData(); + ConstString result(output.empty() ? llvm::StringRef("") : output); if (log) log->Printf("SBCommandReturnObject(%p)::GetError () => \"%s\"", - static_cast(m_opaque_ap.get()), - m_opaque_ap->GetErrorData()); + static_cast(m_opaque_ap.get()), result.AsCString()); - return m_opaque_ap->GetErrorData(); + return result.AsCString(); } if (log) @@ -94,11 +97,11 @@ const char *SBCommandReturnObject::GetError() { } size_t SBCommandReturnObject::GetOutputSize() { - return (m_opaque_ap ? strlen(m_opaque_ap->GetOutputData()) : 0); + return (m_opaque_ap ? m_opaque_ap->GetOutputData().size() : 0); } size_t SBCommandReturnObject::GetErrorSize() { - return (m_opaque_ap ? strlen(m_opaque_ap->GetErrorData()) : 0); + return (m_opaque_ap ? m_opaque_ap->GetErrorData().size() : 0); } size_t SBCommandReturnObject::PutOutput(FILE *fh) { diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 31ac0a7..1845b12 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -1295,7 +1295,7 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr, "SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value " "= %u) %s", expr, options.GetFetchDynamicValue(), - frame_description.GetString().c_str()); + frame_description.GetData()); } exe_results = target->EvaluateExpression(expr, frame, expr_value_sp, diff --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp index 0ade453..858e949 100644 --- a/lldb/source/API/SBStream.cpp +++ b/lldb/source/API/SBStream.cpp @@ -63,8 +63,7 @@ void SBStream::RedirectToFile(const char *path, bool append) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) - local_data.swap( - static_cast(m_opaque_ap.get())->GetString()); + local_data = static_cast(m_opaque_ap.get())->GetString(); } StreamFile *stream_file = new StreamFile; uint32_t open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate; @@ -97,8 +96,7 @@ void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) - local_data.swap( - static_cast(m_opaque_ap.get())->GetString()); + local_data = static_cast(m_opaque_ap.get())->GetString(); } m_opaque_ap.reset(new StreamFile(fh, transfer_fh_ownership)); @@ -119,8 +117,7 @@ void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) - local_data.swap( - static_cast(m_opaque_ap.get())->GetString()); + local_data = static_cast(m_opaque_ap.get())->GetString(); } m_opaque_ap.reset(new StreamFile(::fdopen(fd, "w"), transfer_fh_ownership)); @@ -152,6 +149,6 @@ void SBStream::Clear() { if (m_is_file) m_opaque_ap.reset(); else - static_cast(m_opaque_ap.get())->GetString().clear(); + static_cast(m_opaque_ap.get())->Clear(); } } diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 7515343..fa58e72 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -2133,7 +2133,7 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr, "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = " "%u) %s", expr, options.GetFetchDynamicValue(), - frame_description.GetString().c_str()); + frame_description.GetString().str().c_str()); #endif exe_results = target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); diff --git a/lldb/source/Commands/CommandObjectBreakpoint.cpp b/lldb/source/Commands/CommandObjectBreakpoint.cpp index a144e1e..941dd9a 100644 --- a/lldb/source/Commands/CommandObjectBreakpoint.cpp +++ b/lldb/source/Commands/CommandObjectBreakpoint.cpp @@ -1558,7 +1558,7 @@ protected: if (num_cleared > 0) { Stream &output_stream = result.GetOutputStream(); output_stream.Printf("%d breakpoints cleared:\n", num_cleared); - output_stream << ss.GetData(); + output_stream << ss.GetString(); output_stream.EOL(); result.SetStatus(eReturnStatusSuccessFinishNoResult); } else { @@ -1997,7 +1997,7 @@ protected: StreamString s; bp_sp->GetDescription(&s, eDescriptionLevelBrief); s.EOL(); - result.AppendMessage(s.GetData()); + result.AppendMessage(s.GetString()); } } diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index b94000f..8b32b89 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -948,7 +948,7 @@ protected: CommandObjectHelp::GenerateAdditionalHelpAvenuesMessage( &error_msg_stream, command_name, nullptr, nullptr, generate_apropos, generate_type_lookup); - result.AppendErrorWithFormat("%s", error_msg_stream.GetData()); + result.AppendError(error_msg_stream.GetString()); result.SetStatus(eReturnStatusFailed); } @@ -1286,7 +1286,7 @@ public: else { StreamString stream; stream.Printf("For more information run 'help %s'", name.c_str()); - SetHelp(stream.GetData()); + SetHelp(stream.GetString()); } } @@ -1332,8 +1332,7 @@ protected: } else { // Don't change the status if the command already set it... if (result.GetStatus() == eReturnStatusInvalid) { - if (result.GetOutputData() == nullptr || - result.GetOutputData()[0] == '\0') + if (result.GetOutputData().empty()) result.SetStatus(eReturnStatusSuccessFinishNoResult); else result.SetStatus(eReturnStatusSuccessFinishResult); @@ -1360,7 +1359,7 @@ public: m_fetched_help_long(false) { StreamString stream; stream.Printf("For more information run 'help %s'", name.c_str()); - SetHelp(stream.GetData()); + SetHelp(stream.GetString()); if (ScriptInterpreter *scripter = m_interpreter.GetScriptInterpreter()) GetFlags().Set(scripter->GetFlagsForCommandObject(cmd_obj_sp)); } @@ -1421,8 +1420,7 @@ protected: } else { // Don't change the status if the command already set it... if (result.GetStatus() == eReturnStatusInvalid) { - if (result.GetOutputData() == nullptr || - result.GetOutputData()[0] == '\0') + if (result.GetOutputData().empty()) result.SetStatus(eReturnStatusSuccessFinishNoResult); else result.SetStatus(eReturnStatusSuccessFinishResult); diff --git a/lldb/source/Commands/CommandObjectHelp.cpp b/lldb/source/Commands/CommandObjectHelp.cpp index b4a3e01..4a8f01c 100644 --- a/lldb/source/Commands/CommandObjectHelp.cpp +++ b/lldb/source/Commands/CommandObjectHelp.cpp @@ -148,7 +148,7 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) { s.Printf("\n\t%s", matches.GetStringAtIndex(match_idx)); } s.Printf("\n"); - result.AppendError(s.GetData()); + result.AppendError(s.GetString()); result.SetStatus(eReturnStatusFailed); return false; } else if (!sub_cmd_obj) { @@ -156,7 +156,7 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) { GenerateAdditionalHelpAvenuesMessage( &error_msg_stream, cmd_string.c_str(), m_interpreter.GetCommandPrefix(), sub_command.c_str()); - result.AppendErrorWithFormat("%s", error_msg_stream.GetData()); + result.AppendError(error_msg_stream.GetString()); result.SetStatus(eReturnStatusFailed); return false; } else { @@ -199,7 +199,7 @@ bool CommandObjectHelp::DoExecute(Args &command, CommandReturnObject &result) { GenerateAdditionalHelpAvenuesMessage(&error_msg_stream, command.GetArgumentAtIndex(0), m_interpreter.GetCommandPrefix()); - result.AppendErrorWithFormat("%s", error_msg_stream.GetData()); + result.AppendError(error_msg_stream.GetString()); result.SetStatus(eReturnStatusFailed); } } diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 5d0dc11..e49f49f 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -823,7 +823,7 @@ protected: } else { result.AppendErrorWithFormat( "failed to create a value object for: (%s) %s\n", - view_as_type_cstr, name_strm.GetString().c_str()); + view_as_type_cstr, name_strm.GetData()); result.SetStatus(eReturnStatusFailed); return false; } @@ -1577,7 +1577,7 @@ protected: if (!buffer.GetString().empty()) { Error error; - if (process->WriteMemory(addr, buffer.GetString().c_str(), + if (process->WriteMemory(addr, buffer.GetString().data(), buffer.GetString().size(), error) == buffer.GetString().size()) return true; diff --git a/lldb/source/Commands/CommandObjectMultiword.cpp b/lldb/source/Commands/CommandObjectMultiword.cpp index d31bba4..8aa2856 100644 --- a/lldb/source/Commands/CommandObjectMultiword.cpp +++ b/lldb/source/Commands/CommandObjectMultiword.cpp @@ -260,7 +260,7 @@ void CommandObjectMultiword::AproposAllSubCommands(llvm::StringRef prefix, complete_command_name << prefix << " " << command_name; if (sub_cmd_obj->HelpTextContainsWord(search_word)) { - commands_found.AppendString(complete_command_name.GetData()); + commands_found.AppendString(complete_command_name.GetString()); commands_help.AppendString(sub_cmd_obj->GetHelp()); } diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 5d25521..dea996c 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -242,9 +242,9 @@ protected: // a chance to call PushProcessIOHandler(). process_sp->SyncIOHandler(0, 2000); - const char *data = stream.GetData(); - if (data && strlen(data) > 0) - result.AppendMessage(stream.GetData()); + llvm::StringRef data = stream.GetString(); + if (!data.empty()) + result.AppendMessage(data); const char *archname = exe_module_sp->GetArchitecture().GetArchitectureName(); result.AppendMessageWithFormat( @@ -504,8 +504,7 @@ protected: if (error.Success()) { ProcessSP process_sp(target->GetProcessSP()); if (process_sp) { - if (stream.GetData()) - result.AppendMessage(stream.GetData()); + result.AppendMessage(stream.GetString()); result.SetStatus(eReturnStatusSuccessFinishNoResult); result.SetDidChangeProcessState(true); result.SetAbnormalStopWasExpected(true); @@ -706,8 +705,7 @@ protected: if (synchronous_execution) { // If any state changed events had anything to say, add that to the // result - if (stream.GetData()) - result.AppendMessage(stream.GetData()); + result.AppendMessage(stream.GetString()); result.SetDidChangeProcessState(true); result.SetStatus(eReturnStatusSuccessFinishNoResult); diff --git a/lldb/source/Commands/CommandObjectQuit.cpp b/lldb/source/Commands/CommandObjectQuit.cpp index 2f258b7..be55dab 100644 --- a/lldb/source/Commands/CommandObjectQuit.cpp +++ b/lldb/source/Commands/CommandObjectQuit.cpp @@ -73,7 +73,7 @@ bool CommandObjectQuit::DoExecute(Args &command, CommandReturnObject &result) { message.Printf("Quitting LLDB will %s one or more processes. Do you really " "want to proceed", (is_a_detach ? "detach from" : "kill")); - if (!m_interpreter.Confirm(message.GetData(), true)) { + if (!m_interpreter.Confirm(message.GetString(), true)) { result.SetStatus(eReturnStatusFailed); return false; } diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp index fbf69d8..a695589 100644 --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -2463,20 +2463,20 @@ protected: result.AppendErrorWithFormat( "Unable to create the executable or symbol file with " "UUID %s with path %s and symbol file %s", - strm.GetString().c_str(), + strm.GetData(), module_spec.GetFileSpec().GetPath().c_str(), module_spec.GetSymbolFileSpec().GetPath().c_str()); } else { result.AppendErrorWithFormat( "Unable to create the executable or symbol file with " "UUID %s with path %s", - strm.GetString().c_str(), + strm.GetData(), module_spec.GetFileSpec().GetPath().c_str()); } } else { result.AppendErrorWithFormat("Unable to create the executable " "or symbol file with UUID %s", - strm.GetString().c_str()); + strm.GetData()); } result.SetStatus(eReturnStatusFailed); return false; @@ -2486,7 +2486,7 @@ protected: module_spec.GetUUID().Dump(&strm); result.AppendErrorWithFormat( "Unable to locate the executable or symbol file with UUID %s", - strm.GetString().c_str()); + strm.GetData()); result.SetStatus(eReturnStatusFailed); return false; } @@ -4224,7 +4224,7 @@ protected: error_strm.PutCString( "unable to find debug symbols for the current frame"); } - result.AppendError(error_strm.GetData()); + result.AppendError(error_strm.GetString()); } } else { result.AppendError("one or more symbol file paths must be specified, " diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index ccab6ea..9771894 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -675,8 +675,8 @@ protected: if (synchronous_execution) { // If any state changed events had anything to say, add that to the // result - if (stream.GetData()) - result.AppendMessage(stream.GetData()); + if (stream.GetSize() > 0) + result.AppendMessage(stream.GetString()); process->GetThreadList().SetSelectedThreadByID(thread->GetID()); result.SetDidChangeProcessState(true); @@ -853,8 +853,8 @@ public: if (synchronous_execution) { // If any state changed events had anything to say, add that to the // result - if (stream.GetData()) - result.AppendMessage(stream.GetData()); + if (stream.GetSize() > 0) + result.AppendMessage(stream.GetString()); result.SetDidChangeProcessState(true); result.SetStatus(eReturnStatusSuccessFinishNoResult); @@ -1183,8 +1183,8 @@ protected: if (synchronous_execution) { // If any state changed events had anything to say, add that to the // result - if (stream.GetData()) - result.AppendMessage(stream.GetData()); + if (stream.GetSize() > 0) + result.AppendMessage(stream.GetString()); result.SetDidChangeProcessState(true); result.SetStatus(eReturnStatusSuccessFinishNoResult); diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index e991817e..621ef58 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -3010,15 +3010,15 @@ public: m_discovery_function(discovery_func) { StreamString name; name.Printf("type %s info", formatter_name); - SetCommandName(name.GetData()); + SetCommandName(name.GetString()); StreamString help; help.Printf("This command evaluates the provided expression and shows " "which %s is applied to the resulting value (if any).", formatter_name); - SetHelp(help.GetData()); + SetHelp(help.GetString()); StreamString syntax; syntax.Printf("type %s info ", formatter_name); - SetSyntax(syntax.GetData()); + SetSyntax(syntax.GetString()); } ~CommandObjectFormatterInfo() override = default; diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index 6933aba..e2ccf9d 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -716,7 +716,7 @@ bool Address::Dump(Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyleResolvedDescription, DumpStyleInvalid, addr_size)) { s->Address(dereferenced_load_addr, addr_size, " -> ", " "); - s->Write(strm.GetData(), strm.GetSize()); + s->Write(strm.GetString().data(), strm.GetSize()); return true; } } diff --git a/lldb/source/Core/DataExtractor.cpp b/lldb/source/Core/DataExtractor.cpp index 466f111..fbc6e80 100644 --- a/lldb/source/Core/DataExtractor.cpp +++ b/lldb/source/Core/DataExtractor.cpp @@ -1981,7 +1981,7 @@ lldb::offset_t DataExtractor::PutToLog(Log *log, offset_t start_offset, if ((count % num_per_line) == 0) { // Print out any previous string if (sstr.GetSize() > 0) { - log->Printf("%s", sstr.GetData()); + log->PutString(sstr.GetString()); sstr.Clear(); } // Reset string offset and fill the current line string with address: @@ -2019,8 +2019,8 @@ lldb::offset_t DataExtractor::PutToLog(Log *log, offset_t start_offset, } } - if (sstr.GetSize() > 0) - log->Printf("%s", sstr.GetData()); + if (!sstr.Empty()) + log->PutString(sstr.GetString()); return offset; // Return the offset at which we ended up } diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 1577a38..24715ec 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -320,7 +320,7 @@ Error Debugger::SetPropertyValue(const ExecutionContext *exe_ctx, stream_sp->Printf("%s\n", error.AsCString()); } if (feedback_stream.GetSize()) - stream_sp->Printf("%s", feedback_stream.GetData()); + stream_sp->PutCString(feedback_stream.GetString()); } } } diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp index 577f2f6..c55ad1c 100644 --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -735,7 +735,7 @@ void Instruction::Dump(lldb_private::Stream *s, uint32_t max_opcode_byte_size, ss.PutCString(" ; "); ss.PutCString(m_comment); } - s->Write(ss.GetData(), ss.GetSize()); + s->PutCString(ss.GetString()); } bool Instruction::DumpEmulation(const ArchSpec &arch) { diff --git a/lldb/source/Core/EmulateInstruction.cpp b/lldb/source/Core/EmulateInstruction.cpp index 800ff8e..4ad5b4e 100644 --- a/lldb/source/Core/EmulateInstruction.cpp +++ b/lldb/source/Core/EmulateInstruction.cpp @@ -194,8 +194,8 @@ bool EmulateInstruction::WriteMemoryUnsigned(const Context &context, StreamString strm(Stream::eBinary, GetAddressByteSize(), GetByteOrder()); strm.PutMaxHex64(uval, uval_byte_size); - size_t bytes_written = m_write_mem_callback(this, m_baton, context, addr, - strm.GetData(), uval_byte_size); + size_t bytes_written = m_write_mem_callback( + this, m_baton, context, addr, strm.GetString().data(), uval_byte_size); return (bytes_written == uval_byte_size); } diff --git a/lldb/source/Core/Error.cpp b/lldb/source/Core/Error.cpp index d91f16d..2369612 100644 --- a/lldb/source/Core/Error.cpp +++ b/lldb/source/Core/Error.cpp @@ -264,15 +264,14 @@ void Error::SetErrorToGenericError() { // The error string value will remain until the error value is // cleared or a new error value/type is assigned. //---------------------------------------------------------------------- -void Error::SetErrorString(const char *err_str) { - if (err_str != nullptr && err_str[0]) { - // If we have an error string, we should always at least have - // an error set to a generic value. +void Error::SetErrorString(llvm::StringRef err_str) { + if (!err_str.empty()) { + // If we have an error string, we should always at least have an error + // set to a generic value. if (Success()) SetErrorToGenericError(); - m_string = err_str; - } else - m_string.clear(); + } + m_string = err_str; } //------------------------------------------------------------------ diff --git a/lldb/source/Core/Event.cpp b/lldb/source/Core/Event.cpp index 85da9b8..bd57198 100644 --- a/lldb/source/Core/Event.cpp +++ b/lldb/source/Core/Event.cpp @@ -64,7 +64,7 @@ void Event::Dump(Stream *s) const { static_cast(this), static_cast(broadcaster), broadcaster->GetBroadcasterName().GetCString(), m_type, - event_name.GetString().c_str()); + event_name.GetData()); else s->Printf("%p Event: broadcaster = %p (%s), type = 0x%8.8x, data = ", static_cast(this), diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp index 85965be..bd2e536 100644 --- a/lldb/source/Core/FormatEntity.cpp +++ b/lldb/source/Core/FormatEntity.cpp @@ -829,7 +829,7 @@ static bool DumpValue(Stream &s, const SymbolContext *sc, bitfield_name.Printf("%s:%d", target->GetTypeName().AsCString(), target->GetBitfieldBitSize()); lldb::TypeNameSpecifierImplSP type_sp( - new TypeNameSpecifierImpl(bitfield_name.GetData(), false)); + new TypeNameSpecifierImpl(bitfield_name.GetString(), false)); if (val_obj_display == ValueObject::eValueObjectRepresentationStyleSummary && !DataVisualization::GetSummaryForType(type_sp)) @@ -866,7 +866,7 @@ static bool DumpValue(Stream &s, const SymbolContext *sc, // should not happen if (success) - s << str_temp.GetData(); + s << str_temp.GetString(); return true; } else { if (was_plain_var) // if ${var} @@ -1507,7 +1507,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, sc, exe_ctx, Language::FunctionNameRepresentation::eName, ss); } if (language_plugin_handled) { - s.PutCString(ss.GetData()); + s << ss.GetString(); return true; } else { const char *name = nullptr; @@ -1549,7 +1549,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, ss); } if (language_plugin_handled) { - s.PutCString(ss.GetData()); + s << ss.GetString(); return true; } else { ConstString name; @@ -1578,7 +1578,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, sc, exe_ctx, Language::FunctionNameRepresentation::eNameWithArgs, ss); } if (language_plugin_handled) { - s.PutCString(ss.GetData()); + s << ss.GetString(); return true; } else { // Print the function name with arguments in it @@ -1662,7 +1662,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, ValueObjectSP var_value_sp( ValueObjectVariable::Create(exe_scope, var_sp)); StreamString ss; - const char *var_representation = nullptr; + llvm::StringRef var_representation; const char *var_name = var_value_sp->GetName().GetCString(); if (var_value_sp->GetCompilerType().IsValid()) { if (var_value_sp && exe_scope->CalculateTarget()) @@ -1681,7 +1681,7 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, ""); format.FormatObject(var_value_sp.get(), buffer, TypeSummaryOptions()); - var_representation = buffer.c_str(); + var_representation = buffer; } else var_value_sp->DumpPrintableRepresentation( ss, ValueObject::ValueObjectRepresentationStyle:: @@ -1691,13 +1691,13 @@ bool FormatEntity::Format(const Entry &entry, Stream &s, false); } - if (ss.GetData() && ss.GetSize()) - var_representation = ss.GetData(); + if (!ss.GetString().empty()) + var_representation = ss.GetString(); if (arg_idx > 0) s.PutCString(", "); if (var_value_sp->GetError().Success()) { - if (var_representation) - s.Printf("%s=%s", var_name, var_representation); + if (!var_representation.empty()) + s.Printf("%s=%s", var_name, var_representation.str().c_str()); else s.Printf("%s=%s at %s", var_name, var_value_sp->GetTypeName().GetCString(), @@ -1888,8 +1888,7 @@ static Error ParseEntry(const llvm::StringRef &format_str, "access one of its children: ", entry_def->name); DumpCommaSeparatedChildEntryNames(error_strm, entry_def); - error.SetErrorStringWithFormat("%s", - error_strm.GetString().c_str()); + error.SetErrorStringWithFormat("%s", error_strm.GetData()); } else if (sep_char == ':') { // Any value whose separator is a with a ':' means this value has a // string argument @@ -1926,7 +1925,7 @@ static Error ParseEntry(const llvm::StringRef &format_str, error_strm.Printf("invalid member '%s' in '%s'. Valid members are: ", key.str().c_str(), parent->name); DumpCommaSeparatedChildEntryNames(error_strm, parent); - error.SetErrorStringWithFormat("%s", error_strm.GetString().c_str()); + error.SetErrorStringWithFormat("%s", error_strm.GetData()); return error; } diff --git a/lldb/source/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp index 315d20e..e123fdb 100644 --- a/lldb/source/Core/IOHandler.cpp +++ b/lldb/source/Core/IOHandler.cpp @@ -2422,7 +2422,7 @@ public: if (FormatEntity::Format(m_format, strm, &sc, &exe_ctx, nullptr, nullptr, false, false)) { int right_pad = 1; - window.PutCStringTruncated(strm.GetString().c_str(), right_pad); + window.PutCStringTruncated(strm.GetString().str().c_str(), right_pad); } } } @@ -2481,7 +2481,7 @@ public: if (FormatEntity::Format(m_format, strm, nullptr, &exe_ctx, nullptr, nullptr, false, false)) { int right_pad = 1; - window.PutCStringTruncated(strm.GetString().c_str(), right_pad); + window.PutCStringTruncated(strm.GetString().str().c_str(), right_pad); } } } @@ -2571,7 +2571,7 @@ public: if (FormatEntity::Format(m_format, strm, nullptr, &exe_ctx, nullptr, nullptr, false, false)) { int right_pad = 1; - window.PutCStringTruncated(strm.GetString().c_str(), right_pad); + window.PutCStringTruncated(strm.GetString().str().c_str(), right_pad); } } } @@ -3312,7 +3312,7 @@ HelpDialogDelegate::HelpDialogDelegate(const char *text, StreamString key_description; key_description.Printf("%10s - %s", CursesKeyToCString(key->ch), key->description); - m_text.AppendString(std::move(key_description.GetString())); + m_text.AppendString(key_description.GetString()); } } } @@ -3597,8 +3597,8 @@ public: thread_menu_title.Printf(" %s", queue_name); } menu.AddSubmenu( - MenuSP(new Menu(thread_menu_title.GetString().c_str(), nullptr, - menu_char, thread_sp->GetID()))); + MenuSP(new Menu(thread_menu_title.GetString().str().c_str(), + nullptr, menu_char, thread_sp->GetID()))); } } else if (submenus.size() > 7) { // Remove the separator and any other thread submenu items @@ -3757,7 +3757,7 @@ public: if (thread && FormatEntity::Format(m_format, strm, nullptr, &exe_ctx, nullptr, nullptr, false, false)) { window.MoveCursor(40, 0); - window.PutCStringTruncated(strm.GetString().c_str(), 1); + window.PutCStringTruncated(strm.GetString().str().c_str(), 1); } window.MoveCursor(60, 0); @@ -3986,7 +3986,7 @@ public: window.AttributeOn(A_REVERSE); window.MoveCursor(1, 1); window.PutChar(' '); - window.PutCStringTruncated(m_title.GetString().c_str(), 1); + window.PutCStringTruncated(m_title.GetString().str().c_str(), 1); int x = window.GetCursorX(); if (x < window_width - 1) { window.Printf("%*s", window_width - x - 1, ""); @@ -4208,7 +4208,7 @@ public: strm.Printf("%s", mnemonic); int right_pad = 1; - window.PutCStringTruncated(strm.GetString().c_str(), right_pad); + window.PutCStringTruncated(strm.GetData(), right_pad); if (is_pc_line && frame_sp && frame_sp->GetConcreteFrameIndex() == 0) { diff --git a/lldb/source/Core/Log.cpp b/lldb/source/Core/Log.cpp index 30b6188..5319500 100644 --- a/lldb/source/Core/Log.cpp +++ b/lldb/source/Core/Log.cpp @@ -51,6 +51,7 @@ Flags &Log::GetMask() { return m_mask_bits; } const Flags &Log::GetMask() const { return m_mask_bits; } void Log::PutCString(const char *cstr) { Printf("%s", cstr); } +void Log::PutString(llvm::StringRef str) { PutCString(str.str().c_str()); } //---------------------------------------------------------------------- // Simple variable argument logging with flags. diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 9ce03d6..220773b 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -316,7 +316,7 @@ ObjectFile *Module::GetMemoryObjectFile(const lldb::ProcessSP &process_sp, if (m_objfile_sp) { StreamString s; s.Printf("0x%16.16" PRIx64, header_addr); - m_object_name.SetCString(s.GetData()); + m_object_name.SetString(s.GetString()); // Once we get the object file, update our module with the object // file's @@ -1118,7 +1118,7 @@ void Module::ReportError(const char *format, ...) { if (last_char != '\n' || last_char != '\r') strm.EOL(); } - Host::SystemLog(Host::eSystemLogError, "%s", strm.GetString().c_str()); + Host::SystemLog(Host::eSystemLogError, "%s", strm.GetData()); } } @@ -1152,7 +1152,7 @@ void Module::ReportErrorIfModifyDetected(const char *format, ...) { } strm.PutCString("The debug session should be aborted as the original " "debug information has been overwritten.\n"); - Host::SystemLog(Host::eSystemLogError, "%s", strm.GetString().c_str()); + Host::SystemLog(Host::eSystemLogError, "%s", strm.GetData()); } } } @@ -1176,7 +1176,7 @@ void Module::ReportWarning(const char *format, ...) { if (last_char != '\n' || last_char != '\r') strm.EOL(); } - Host::SystemLog(Host::eSystemLogWarning, "%s", strm.GetString().c_str()); + Host::SystemLog(Host::eSystemLogWarning, "%s", strm.GetData()); } } @@ -1189,7 +1189,7 @@ void Module::LogMessage(Log *log, const char *format, ...) { va_start(args, format); log_message.PrintfVarArg(format, args); va_end(args); - log->PutCString(log_message.GetString().c_str()); + log->PutCString(log_message.GetData()); } } @@ -1208,7 +1208,7 @@ void Module::LogMessageVerboseBacktrace(Log *log, const char *format, ...) { llvm::sys::PrintStackTrace(stream); log_message.PutCString(back_trace); } - log->PutCString(log_message.GetString().c_str()); + log->PutCString(log_message.GetData()); } } diff --git a/lldb/source/Core/RegisterValue.cpp b/lldb/source/Core/RegisterValue.cpp index 509919d..62d8305 100644 --- a/lldb/source/Core/RegisterValue.cpp +++ b/lldb/source/Core/RegisterValue.cpp @@ -46,13 +46,13 @@ bool RegisterValue::Dump(Stream *s, const RegisterInfo *reg_info, format_string.Printf("%%%us", reg_name_right_align_at); else format_string.Printf("%%s"); - const char *fmt = format_string.GetData(); + std::string fmt = format_string.GetString(); if (prefix_with_name) { if (reg_info->name) { - s->Printf(fmt, reg_info->name); + s->Printf(fmt.c_str(), reg_info->name); name_printed = true; } else if (reg_info->alt_name) { - s->Printf(fmt, reg_info->alt_name); + s->Printf(fmt.c_str(), reg_info->alt_name); prefix_with_alt_name = false; name_printed = true; } @@ -61,12 +61,12 @@ bool RegisterValue::Dump(Stream *s, const RegisterInfo *reg_info, if (name_printed) s->PutChar('/'); if (reg_info->alt_name) { - s->Printf(fmt, reg_info->alt_name); + s->Printf(fmt.c_str(), reg_info->alt_name); name_printed = true; } else if (!name_printed) { // No alternate name but we were asked to display a name, so show the // main name - s->Printf(fmt, reg_info->name); + s->Printf(fmt.c_str(), reg_info->name); name_printed = true; } } diff --git a/lldb/source/Core/StreamString.cpp b/lldb/source/Core/StreamString.cpp index cb08808..4616488 100644 --- a/lldb/source/Core/StreamString.cpp +++ b/lldb/source/Core/StreamString.cpp @@ -34,8 +34,6 @@ void StreamString::Clear() { m_packet.clear(); } bool StreamString::Empty() const { return GetSize() == 0; } -const char *StreamString::GetData() const { return m_packet.c_str(); } - size_t StreamString::GetSize() const { return m_packet.size(); } size_t StreamString::GetSizeOfLastLine() const { @@ -49,9 +47,7 @@ size_t StreamString::GetSizeOfLastLine() const { } } -std::string &StreamString::GetString() { return m_packet; } - -const std::string &StreamString::GetString() const { return m_packet; } +llvm::StringRef StreamString::GetString() const { return m_packet; } void StreamString::FillLastLineToColumn(uint32_t column, char fill_char) { const size_t length = m_packet.size(); diff --git a/lldb/source/Core/StringList.cpp b/lldb/source/Core/StringList.cpp index cde02e1..226db21 100644 --- a/lldb/source/Core/StringList.cpp +++ b/lldb/source/Core/StringList.cpp @@ -204,7 +204,7 @@ std::string StringList::CopyList(const char *item_preamble, strm << item_preamble; strm << GetStringAtIndex(i); } - return std::string(strm.GetData()); + return strm.GetString(); } StringList &StringList::operator<<(const char *str) { diff --git a/lldb/source/Core/StructuredData.cpp b/lldb/source/Core/StructuredData.cpp index 48c368d..1e190f5 100644 --- a/lldb/source/Core/StructuredData.cpp +++ b/lldb/source/Core/StructuredData.cpp @@ -1,5 +1,4 @@ -//===---------------------StructuredData.cpp ---------------------*- C++ -//-*-===// +//===---------------------StructuredData.cpp ---------------------*- C++-*-===// // // The LLVM Compiler Infrastructure // @@ -213,7 +212,7 @@ StructuredData::Object::GetObjectForDotSeparatedPath(llvm::StringRef path) { void StructuredData::Object::DumpToStdout(bool pretty_print) const { StreamString stream; Dump(stream, pretty_print); - printf("%s\n", stream.GetString().c_str()); + printf("%s\n", stream.GetData()); } void StructuredData::Array::Dump(Stream &s, bool pretty_print) const { diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index cd6bc89..e349e03 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -378,7 +378,7 @@ const char *ValueObject::GetLocationAsCStringImpl(const Value &value, uint32_t addr_nibble_size = data.GetAddressByteSize() * 2; sstr.Printf("0x%*.*llx", addr_nibble_size, addr_nibble_size, value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS)); - m_location_str.swap(sstr.GetString()); + m_location_str = sstr.GetString(); } break; } } @@ -944,7 +944,7 @@ bool ValueObject::SetData(DataExtractor &data, Error &error) { static bool CopyStringDataToBufferSP(const StreamString &source, lldb::DataBufferSP &destination) { destination.reset(new DataBufferHeap(source.GetSize() + 1, 0)); - memcpy(destination->GetBytes(), source.GetString().c_str(), source.GetSize()); + memcpy(destination->GetBytes(), source.GetString().data(), source.GetSize()); return true; } @@ -1137,7 +1137,7 @@ const char *ValueObject::GetObjectDescription() { } if (runtime && runtime->GetObjectDescription(s, *this)) { - m_object_desc_str.append(s.GetData()); + m_object_desc_str.append(s.GetString()); } if (m_object_desc_str.empty()) @@ -1414,14 +1414,12 @@ bool ValueObject::DumpPrintableRepresentation( bool var_success = false; { - const char *cstr = NULL; + llvm::StringRef str; // this is a local stream that we are using to ensure that the data pointed - // to by cstr survives - // long enough for us to copy it to its destination - it is necessary to - // have this temporary storage - // area for cases where our desired output is not backed by some other - // longer-term storage + // to by cstr survives long enough for us to copy it to its destination - it + // is necessary to have this temporary storage area for cases where our + // desired output is not backed by some other longer-term storage StreamString strm; if (custom_format != eFormatInvalid) @@ -1429,55 +1427,55 @@ bool ValueObject::DumpPrintableRepresentation( switch (val_obj_display) { case eValueObjectRepresentationStyleValue: - cstr = GetValueAsCString(); + str = GetValueAsCString(); break; case eValueObjectRepresentationStyleSummary: - cstr = GetSummaryAsCString(); + str = GetSummaryAsCString(); break; case eValueObjectRepresentationStyleLanguageSpecific: - cstr = GetObjectDescription(); + str = GetObjectDescription(); break; case eValueObjectRepresentationStyleLocation: - cstr = GetLocationAsCString(); + str = GetLocationAsCString(); break; case eValueObjectRepresentationStyleChildrenCount: strm.Printf("%" PRIu64 "", (uint64_t)GetNumChildren()); - cstr = strm.GetString().c_str(); + str = strm.GetString(); break; case eValueObjectRepresentationStyleType: - cstr = GetTypeName().AsCString(); + str = GetTypeName().GetStringRef(); break; case eValueObjectRepresentationStyleName: - cstr = GetName().AsCString(); + str = GetName().GetStringRef(); break; case eValueObjectRepresentationStyleExpressionPath: GetExpressionPath(strm, false); - cstr = strm.GetString().c_str(); + str = strm.GetString(); break; } - if (!cstr) { + if (str.empty()) { if (val_obj_display == eValueObjectRepresentationStyleValue) - cstr = GetSummaryAsCString(); + str = GetSummaryAsCString(); else if (val_obj_display == eValueObjectRepresentationStyleSummary) { if (!CanProvideValue()) { strm.Printf("%s @ %s", GetTypeName().AsCString(), GetLocationAsCString()); - cstr = strm.GetString().c_str(); + str = strm.GetString(); } else - cstr = GetValueAsCString(); + str = GetValueAsCString(); } } - if (cstr) - s.PutCString(cstr); + if (!str.empty()) + s << str; else { if (m_error.Fail()) { if (do_dump_error) @@ -3352,11 +3350,11 @@ ValueObjectSP ValueObject::Dereference(Error &error) { if (is_pointer_or_reference_type) error.SetErrorStringWithFormat("dereference failed: (%s) %s", GetTypeName().AsCString(""), - strm.GetString().c_str()); + strm.GetData()); else error.SetErrorStringWithFormat("not a pointer or reference type: (%s) %s", GetTypeName().AsCString(""), - strm.GetString().c_str()); + strm.GetData()); return ValueObjectSP(); } } @@ -3375,7 +3373,7 @@ ValueObjectSP ValueObject::AddressOf(Error &error) { StreamString expr_path_strm; GetExpressionPath(expr_path_strm, true); error.SetErrorStringWithFormat("'%s' is not in memory", - expr_path_strm.GetString().c_str()); + expr_path_strm.GetData()); } break; case eAddressTypeFile: @@ -3398,7 +3396,7 @@ ValueObjectSP ValueObject::AddressOf(Error &error) { StreamString expr_path_strm; GetExpressionPath(expr_path_strm, true); error.SetErrorStringWithFormat("'%s' doesn't have a valid address", - expr_path_strm.GetString().c_str()); + expr_path_strm.GetData()); } return m_addr_of_valobj_sp; diff --git a/lldb/source/DataFormatters/FormatManager.cpp b/lldb/source/DataFormatters/FormatManager.cpp index 07e2b77..6e5fdf9 100644 --- a/lldb/source/DataFormatters/FormatManager.cpp +++ b/lldb/source/DataFormatters/FormatManager.cpp @@ -1,5 +1,4 @@ -//===-- FormatManager.cpp -------------------------------------------*- C++ -//-*-===// +//===-- FormatManager.cpp ----------------------------------------*- C++-*-===// // // The LLVM Compiler Infrastructure // @@ -183,7 +182,7 @@ void FormatManager::GetPossibleMatches( if (valobj.GetBitfieldBitSize() > 0) { StreamString sstring; sstring.Printf("%s:%d", type_name.AsCString(), valobj.GetBitfieldBitSize()); - ConstString bitfieldname = ConstString(sstring.GetData()); + ConstString bitfieldname(sstring.GetString()); entries.push_back( {bitfieldname, 0, did_strip_ptr, did_strip_ref, did_strip_typedef}); reason |= lldb_private::eFormatterChoiceCriterionStrippedBitField; diff --git a/lldb/source/DataFormatters/TypeCategory.cpp b/lldb/source/DataFormatters/TypeCategory.cpp index 5f4863a..db3372c 100644 --- a/lldb/source/DataFormatters/TypeCategory.cpp +++ b/lldb/source/DataFormatters/TypeCategory.cpp @@ -1,5 +1,4 @@ -//===-- TypeCategory.cpp -------------------------------------------*- C++ -//-*-===// +//===-- TypeCategory.cpp -----------------------------------------*- C++-*-===// // // The LLVM Compiler Infrastructure // @@ -638,7 +637,7 @@ std::string TypeCategoryImpl::GetDescription() { idx + 1 < GetNumLanguages() ? ", " : ""); } if (print_lang) - stream.Printf("%s", lang_stream.GetData()); + stream.PutCString(lang_stream.GetString()); stream.PutChar(')'); - return stream.GetData(); + return stream.GetString(); } diff --git a/lldb/source/DataFormatters/TypeFormat.cpp b/lldb/source/DataFormatters/TypeFormat.cpp index 1ec5208..8bd369b 100644 --- a/lldb/source/DataFormatters/TypeFormat.cpp +++ b/lldb/source/DataFormatters/TypeFormat.cpp @@ -63,7 +63,7 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject *valobj, data.Dump(®_sstr, 0, GetFormat(), reg_info->byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, 0, 0, exe_ctx.GetBestExecutionContextScope()); - dest.swap(reg_sstr.GetString()); + dest = reg_sstr.GetString(); } } else { CompilerType compiler_type = value.GetCompilerType(); @@ -115,10 +115,7 @@ bool TypeFormatImpl_Format::FormatObject(ValueObject *valobj, // return from here, but that's about as severe as we get // CompilerType::DumpTypeValue() should always return // something, even if that something is an error message - if (sstr.GetString().empty()) - dest.clear(); - else - dest.swap(sstr.GetString()); + dest = sstr.GetString(); } } return !dest.empty(); @@ -196,7 +193,7 @@ bool TypeFormatImpl_EnumType::FormatObject(ValueObject *valobj, data.GetByteSize(), 0, 0, exe_ctx.GetBestExecutionContextScope()); if (!sstr.GetString().empty()) - dest.swap(sstr.GetString()); + dest = sstr.GetString(); return !dest.empty(); } diff --git a/lldb/source/DataFormatters/TypeSummary.cpp b/lldb/source/DataFormatters/TypeSummary.cpp index 6a192d4..610d2fe 100644 --- a/lldb/source/DataFormatters/TypeSummary.cpp +++ b/lldb/source/DataFormatters/TypeSummary.cpp @@ -98,7 +98,7 @@ bool StringSummaryFormat::FormatObject(ValueObject *valobj, std::string &retval, if (IsOneLiner()) { ValueObjectPrinter printer(valobj, &s, DumpValueObjectOptions()); printer.PrintChildrenOneLiner(HideNames(valobj)); - retval.assign(s.GetData()); + retval = s.GetString(); return true; } else { if (FormatEntity::Format(m_format, s, &sc, &exe_ctx, @@ -141,7 +141,7 @@ bool CXXFunctionSummaryFormat::FormatObject(ValueObject *valobj, StreamString stream; if (!m_impl || m_impl(*valobj, stream, options) == false) return false; - dest.assign(stream.GetData()); + dest = stream.GetString(); return true; } diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp index 9e66d8d..d6efe78 100644 --- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp +++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp @@ -1,5 +1,4 @@ -//===-- ValueObjectPrinter.cpp -------------------------------------*- C++ -//-*-===// +//===-- ValueObjectPrinter.cpp -----------------------------------*- C++-*-===// // // The LLVM Compiler Infrastructure // @@ -302,22 +301,22 @@ void ValueObjectPrinter::PrintDecl() { } if (m_options.m_decl_printing_helper) { - ConstString type_name_cstr(typeName.GetData()); - ConstString var_name_cstr(varName.GetData()); + ConstString type_name_cstr(typeName.GetString()); + ConstString var_name_cstr(varName.GetString()); StreamString dest_stream; if (m_options.m_decl_printing_helper(type_name_cstr, var_name_cstr, m_options, dest_stream)) { decl_printed = true; - m_stream->Printf("%s", dest_stream.GetData()); + m_stream->PutCString(dest_stream.GetString()); } } // if the helper failed, or there is none, do a default thing if (!decl_printed) { - if (typeName.GetSize()) + if (!typeName.Empty()) m_stream->Printf("(%s) ", typeName.GetData()); - if (varName.GetSize()) + if (!varName.Empty()) m_stream->Printf("%s =", varName.GetData()); else if (!m_options.m_hide_name) m_stream->Printf(" ="); diff --git a/lldb/source/DataFormatters/VectorType.cpp b/lldb/source/DataFormatters/VectorType.cpp index 7769461..652bde7 100644 --- a/lldb/source/DataFormatters/VectorType.cpp +++ b/lldb/source/DataFormatters/VectorType.cpp @@ -211,7 +211,7 @@ public: StreamString idx_name; idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx); - child_sp->SetName(ConstString(idx_name.GetData())); + child_sp->SetName(ConstString(idx_name.GetString())); child_sp->SetFormat(m_item_format); diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index 2b57b9f..9ad2b33 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -427,7 +427,7 @@ void IRExecutionUnit::GetRunnableInfo(Error &error, lldb::addr_t &func_addr, m_failed_lookups.clear(); - error.SetErrorString(ss.GetData()); + error.SetErrorString(ss.GetString()); return; } diff --git a/lldb/source/Expression/LLVMUserExpression.cpp b/lldb/source/Expression/LLVMUserExpression.cpp index 379dd98..c5df781 100644 --- a/lldb/source/Expression/LLVMUserExpression.cpp +++ b/lldb/source/Expression/LLVMUserExpression.cpp @@ -153,7 +153,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, StreamString ss; if (!call_plan_sp || !call_plan_sp->ValidatePlan(&ss)) { - diagnostic_manager.PutString(eDiagnosticSeverityError, ss.GetData()); + diagnostic_manager.PutString(eDiagnosticSeverityError, ss.GetString()); return lldb::eExpressionSetupError; } diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 80fb244..6ddd4a4 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -409,7 +409,7 @@ public: } } - log->PutCString(dump_stream.GetData()); + log->PutString(dump_stream.GetString()); } void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override {} @@ -749,7 +749,7 @@ public: } } - log->PutCString(dump_stream.GetData()); + log->PutString(dump_stream.GetString()); } void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override { @@ -1019,7 +1019,7 @@ public: } } - log->PutCString(dump_stream.GetData()); + log->PutString(dump_stream.GetString()); } void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override { @@ -1156,7 +1156,7 @@ public: } } - log->PutCString(dump_stream.GetData()); + log->PutString(dump_stream.GetString()); } void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override {} @@ -1332,7 +1332,7 @@ public: } } - log->PutCString(dump_stream.GetData()); + log->PutString(dump_stream.GetString()); } void Wipe(IRMemoryMap &map, lldb::addr_t process_address) override {} diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm index 47fd462..50db9f5 100644 --- a/lldb/source/Host/macosx/Host.mm +++ b/lldb/source/Host/macosx/Host.mm @@ -478,7 +478,6 @@ LaunchInNewTerminalWithAppleScript(const char *exe_path, StreamString applescript_source; - const char *tty_command = command.GetString().c_str(); // if (tty_name && tty_name[0]) // { // applescript_source.Printf (applscript_in_existing_tty, @@ -487,13 +486,15 @@ LaunchInNewTerminalWithAppleScript(const char *exe_path, // } // else // { - applescript_source.Printf(applscript_in_new_tty, tty_command); + applescript_source.Printf(applscript_in_new_tty, + command.GetString().str().c_str()); // } - const char *script_source = applescript_source.GetString().c_str(); // puts (script_source); NSAppleScript *applescript = [[NSAppleScript alloc] - initWithSource:[NSString stringWithCString:script_source + initWithSource:[NSString stringWithCString:applescript_source.GetString() + .str() + .c_str() encoding:NSUTF8StringEncoding]]; lldb::pid_t pid = LLDB_INVALID_PROCESS_ID; @@ -557,7 +558,7 @@ void Host::SetCrashDescriptionWithFormat(const char *format, ...) { if (format) { va_list args; va_start(args, format); - g_crash_description.GetString().clear(); + g_crash_description.GetString() = llvm::StringRef(""); g_crash_description.PrintfVarArg(format, args); va_end(args); __crashreporter_info__ = g_crash_description.GetData(); diff --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp index f6ec94d..1e65a1e 100644 --- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp +++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp @@ -794,5 +794,5 @@ void ConnectionFileDescriptor::InitializeSocket(Socket *socket) { StreamString strm; strm.Printf("connect://%s:%u", tcp_socket->GetRemoteIPAddress().c_str(), tcp_socket->GetRemotePortNumber()); - m_uri.swap(strm.GetString()); + m_uri = strm.GetString(); } diff --git a/lldb/source/Host/windows/Host.cpp b/lldb/source/Host/windows/Host.cpp index 1ca2115..b4a50c4 100644 --- a/lldb/source/Host/windows/Host.cpp +++ b/lldb/source/Host/windows/Host.cpp @@ -230,8 +230,9 @@ Error Host::ShellExpandArguments(ProcessLaunchInfo &launch_info) { int status; std::string output; - RunShellCommand(expand_command.GetData(), launch_info.GetWorkingDirectory(), - &status, nullptr, &output, 10); + std::string command = expand_command.GetString(); + RunShellCommand(command.c_str(), launch_info.GetWorkingDirectory(), &status, + nullptr, &output, 10); if (status != 0) { error.SetErrorStringWithFormat("lldb-argdumper exited with error %d", diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index b989ee1..1e86dea 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/lldb/source/Interpreter/Args.cpp @@ -803,7 +803,7 @@ int64_t Args::StringToOptionEnum(llvm::StringRef s, for (int i = 0; enum_values[i].string_value != nullptr; i++) { strm.Printf("%s\"%s\"", i > 0 ? ", " : "", enum_values[i].string_value); } - error.SetErrorString(strm.GetData()); + error.SetErrorString(strm.GetString()); return fail_value; } @@ -859,7 +859,7 @@ Error Args::StringToFormat(const char *s, lldb::Format &format, if (byte_size_ptr) error_strm.PutCString( "An optional byte size can precede the format character.\n"); - error.SetErrorString(error_strm.GetString().c_str()); + error.SetErrorString(error_strm.GetString()); } if (error.Fail()) @@ -1020,9 +1020,9 @@ std::string Args::ParseAliasOptions(Options &options, int val; while (1) { int long_options_index = -1; - val = - OptionParser::Parse(GetArgumentCount(), GetArgumentVector(), - sstr.GetData(), long_options, &long_options_index); + val = OptionParser::Parse(GetArgumentCount(), GetArgumentVector(), + sstr.GetString(), long_options, + &long_options_index); if (val == -1) break; @@ -1088,7 +1088,8 @@ std::string Args::ParseAliasOptions(Options &options, } if (!option_arg) option_arg = ""; - option_arg_vector->emplace_back(option_str.GetData(), has_arg, option_arg); + option_arg_vector->emplace_back(option_str.GetString(), has_arg, + option_arg); // Find option in the argument list; also see if it was supposed to take // an argument and if one was supplied. Remove option (and argument, if diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp index f31f60f..a8f5343 100644 --- a/lldb/source/Interpreter/CommandAlias.cpp +++ b/lldb/source/Interpreter/CommandAlias.cpp @@ -92,7 +92,7 @@ CommandAlias::CommandAlias(CommandInterpreter &interpreter, translation_and_help.Printf( "(%s) %s", sstr.GetData(), GetUnderlyingCommand()->GetHelp().str().c_str()); - SetHelp(translation_and_help.GetData()); + SetHelp(translation_and_help.GetString()); } } } diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 8614bda..2047d4a 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -352,8 +352,8 @@ void CommandInterpreter::Initialize() { StreamString defaultshell; defaultshell.Printf("--shell=%s --", HostInfo::GetDefaultShell().GetPath().c_str()); - AddAlias("r", cmd_obj_sp, defaultshell.GetData()); - AddAlias("run", cmd_obj_sp, defaultshell.GetData()); + AddAlias("r", cmd_obj_sp, defaultshell.GetString()); + AddAlias("run", cmd_obj_sp, defaultshell.GetString()); #endif #endif } @@ -1327,7 +1327,7 @@ CommandObject *CommandInterpreter::BuildAliasResult( result_str.Printf("%s", alias_cmd_obj->GetCommandName().str().c_str()); if (!option_arg_vector_sp.get()) { - alias_result = result_str.GetData(); + alias_result = result_str.GetString(); return alias_cmd_obj; } OptionArgVector *option_arg_vector = option_arg_vector_sp.get(); @@ -1368,7 +1368,7 @@ CommandObject *CommandInterpreter::BuildAliasResult( } } - alias_result = result_str.GetData(); + alias_result = result_str.GetString(); return alias_cmd_obj; } @@ -1437,8 +1437,7 @@ Error CommandInterpreter::PreprocessCommand(std::string &command) { scalar.GetValue(&value_strm, show_type); size_t value_string_size = value_strm.GetSize(); if (value_string_size) { - command.insert(start_backtick, value_strm.GetData(), - value_string_size); + command.insert(start_backtick, value_strm.GetString()); pos = start_backtick + value_string_size; continue; } else { @@ -2249,21 +2248,21 @@ void CommandInterpreter::HandleCommands(const StringList &commands, } if (!success || !tmp_result.Succeeded()) { - const char *error_msg = tmp_result.GetErrorData(); - if (error_msg == nullptr || error_msg[0] == '\0') + llvm::StringRef error_msg = tmp_result.GetErrorData(); + if (error_msg.empty()) error_msg = ".\n"; if (options.GetStopOnError()) { result.AppendErrorWithFormat( "Aborting reading of commands after command #%" PRIu64 ": '%s' failed with %s", - (uint64_t)idx, cmd, error_msg); + (uint64_t)idx, cmd, error_msg.str().c_str()); result.SetStatus(eReturnStatusFailed); m_debugger.SetAsyncExecution(old_async_execution); return; } else if (options.GetPrintResults()) { - result.AppendMessageWithFormat("Command #%" PRIu64 - " '%s' failed with %s", - (uint64_t)idx + 1, cmd, error_msg); + result.AppendMessageWithFormat( + "Command #%" PRIu64 " '%s' failed with %s", (uint64_t)idx + 1, cmd, + error_msg.str().c_str()); } } @@ -2546,7 +2545,15 @@ void CommandInterpreter::OutputFormattedHelpText(Stream &strm, StreamString prefix_stream; prefix_stream.Printf(" %-*s %*s ", (int)max_word_len, word_text.data(), (int)separator.size(), separator.data()); - OutputFormattedHelpText(strm, prefix_stream.GetData(), help_text); + OutputFormattedHelpText(strm, prefix_stream.GetString(), help_text); +} + +LLVM_ATTRIBUTE_ALWAYS_INLINE +static size_t nextWordLength(llvm::StringRef S) { + size_t pos = S.find_first_of(' '); + if (pos == llvm::StringRef::npos) + return S.size(); + return pos; } void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text, @@ -2563,22 +2570,24 @@ void CommandInterpreter::OutputHelpText(Stream &strm, llvm::StringRef word_text, const uint32_t max_columns = m_debugger.GetTerminalWidth(); - size_t len = text_strm.GetSize(); - const char *text = text_strm.GetData(); + llvm::StringRef text = text_strm.GetString(); uint32_t chars_left = max_columns; - for (uint32_t i = 0; i < len; i++) { - if ((text[i] == ' ' && ::strchr((text + i + 1), ' ') && - chars_left < static_cast(::strchr((text + i + 1), ' ') - - (text + i))) || - text[i] == '\n') { - chars_left = max_columns - indent_size; + while (!text.empty()) { + if (text.front() == '\n' || + (text.front() == ' ' && nextWordLength(text.ltrim(' ')) < chars_left)) { strm.EOL(); strm.Indent(); + chars_left = max_columns - indent_size; + if (text.front() == '\n') + text = text.drop_front(); + else + text = text.ltrim(' '); } else { - strm.PutChar(text[i]); - chars_left--; + strm.PutChar(text.front()); + --chars_left; + text = text.drop_front(); } } @@ -2707,15 +2716,15 @@ void CommandInterpreter::IOHandlerInputComplete(IOHandler &io_handler, GetProcessOutput(); if (!result.GetImmediateOutputStream()) { - const char *output = result.GetOutputData(); - if (output && output[0]) + llvm::StringRef output = result.GetOutputData(); + if (!output.empty()) io_handler.GetOutputStreamFile()->PutCString(output); } // Now emit the command error text from the command we just executed if (!result.GetImmediateErrorStream()) { - const char *error = result.GetErrorData(); - if (error && error[0]) + llvm::StringRef error = result.GetErrorData(); + if (!error.empty()) io_handler.GetErrorStreamFile()->PutCString(error); } } @@ -2993,7 +3002,7 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line, for (uint32_t i = 0; i < num_matches; ++i) { error_msg.Printf("\t%s\n", matches.GetStringAtIndex(i)); } - result.AppendRawError(error_msg.GetString().c_str()); + result.AppendRawError(error_msg.GetString()); } else { // We didn't have only one match, otherwise we wouldn't get here. assert(num_matches == 0); @@ -3029,18 +3038,16 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line, std::string gdb_format_option("--gdb-format="); gdb_format_option += (suffix.c_str() + 1); - bool inserted = false; - std::string &cmd = revised_command_line.GetString(); + std::string cmd = revised_command_line.GetString(); size_t arg_terminator_idx = FindArgumentTerminator(cmd); if (arg_terminator_idx != std::string::npos) { // Insert the gdb format option before the "--" that terminates // options gdb_format_option.append(1, ' '); cmd.insert(arg_terminator_idx, gdb_format_option); - inserted = true; - } - - if (!inserted) + revised_command_line.Clear(); + revised_command_line.PutCString(cmd); + } else revised_command_line.Printf(" %s", gdb_format_option.c_str()); if (wants_raw_input && @@ -3072,7 +3079,7 @@ CommandInterpreter::ResolveCommandImpl(std::string &command_line, revised_command_line.Printf(" %s", scratch_command.c_str()); if (cmd_obj != NULL) - command_line = revised_command_line.GetData(); + command_line = revised_command_line.GetString(); return cmd_obj; } diff --git a/lldb/source/Interpreter/CommandObject.cpp b/lldb/source/Interpreter/CommandObject.cpp index a7f590fd..4c6ec8e 100644 --- a/lldb/source/Interpreter/CommandObject.cpp +++ b/lldb/source/Interpreter/CommandObject.cpp @@ -74,7 +74,7 @@ llvm::StringRef CommandObject::GetSyntax() { syntax_str.PutCString("-- "); GetFormattedCommandArguments(syntax_str); } - m_cmd_syntax = syntax_str.GetData(); + m_cmd_syntax = syntax_str.GetString(); return m_cmd_syntax; } @@ -392,14 +392,14 @@ void CommandObject::GetArgumentHelp(Stream &str, CommandArgumentType arg_type, if (entry->help_function) { llvm::StringRef help_text = entry->help_function(); if (!entry->help_function.self_formatting) { - interpreter.OutputFormattedHelpText(str, name_str.GetData(), "--", + interpreter.OutputFormattedHelpText(str, name_str.GetString(), "--", help_text, name_str.GetSize()); } else { - interpreter.OutputHelpText(str, name_str.GetData(), "--", help_text, + interpreter.OutputHelpText(str, name_str.GetString(), "--", help_text, name_str.GetSize()); } } else - interpreter.OutputFormattedHelpText(str, name_str.GetData(), "--", + interpreter.OutputFormattedHelpText(str, name_str.GetString(), "--", entry->help_text, name_str.GetSize()); } @@ -416,9 +416,7 @@ const char *CommandObject::GetArgumentName(CommandArgumentType arg_type) { if (entry) return entry->arg_name; - StreamString str; - str << "Arg name for type (" << arg_type << ") not in arg table!"; - return str.GetData(); + return nullptr; } bool CommandObject::IsPairType(ArgumentRepetitionType arg_repeat_type) { @@ -503,21 +501,23 @@ void CommandObject::GetFormattedCommandArguments(Stream &str, names.Printf(" | "); names.Printf("%s", GetArgumentName(arg_entry[j].arg_type)); } + + std::string name_str = names.GetString(); switch (arg_entry[0].arg_repetition) { case eArgRepeatPlain: - str.Printf("<%s>", names.GetData()); + str.Printf("<%s>", name_str.c_str()); break; case eArgRepeatPlus: - str.Printf("<%s> [<%s> [...]]", names.GetData(), names.GetData()); + str.Printf("<%s> [<%s> [...]]", name_str.c_str(), name_str.c_str()); break; case eArgRepeatStar: - str.Printf("[<%s> [<%s> [...]]]", names.GetData(), names.GetData()); + str.Printf("[<%s> [<%s> [...]]]", name_str.c_str(), name_str.c_str()); break; case eArgRepeatOptional: - str.Printf("[<%s>]", names.GetData()); + str.Printf("[<%s>]", name_str.c_str()); break; case eArgRepeatRange: - str.Printf("<%s_1> .. <%s_n>", names.GetData(), names.GetData()); + str.Printf("<%s_1> .. <%s_n>", name_str.c_str(), name_str.c_str()); break; // Explicitly test for all the rest of the cases, so if new types get // added we will notice the diff --git a/lldb/source/Interpreter/CommandReturnObject.cpp b/lldb/source/Interpreter/CommandReturnObject.cpp index 53f3bd2..72e66aa 100644 --- a/lldb/source/Interpreter/CommandReturnObject.cpp +++ b/lldb/source/Interpreter/CommandReturnObject.cpp @@ -69,7 +69,7 @@ void CommandReturnObject::AppendMessageWithFormat(const char *format, ...) { sstrm.PrintfVarArg(format, args); va_end(args); - GetOutputStream().Printf("%s", sstrm.GetData()); + GetOutputStream() << sstrm.GetString(); } void CommandReturnObject::AppendWarningWithFormat(const char *format, ...) { @@ -81,7 +81,7 @@ void CommandReturnObject::AppendWarningWithFormat(const char *format, ...) { sstrm.PrintfVarArg(format, args); va_end(args); - GetErrorStream().Printf("warning: %s", sstrm.GetData()); + GetErrorStream() << "warning: " << sstrm.GetString(); } void CommandReturnObject::AppendMessage(llvm::StringRef in_string) { diff --git a/lldb/source/Interpreter/OptionValueEnumeration.cpp b/lldb/source/Interpreter/OptionValueEnumeration.cpp index fe151fa..3ec2829 100644 --- a/lldb/source/Interpreter/OptionValueEnumeration.cpp +++ b/lldb/source/Interpreter/OptionValueEnumeration.cpp @@ -75,7 +75,7 @@ Error OptionValueEnumeration::SetValueFromString(llvm::StringRef value, m_enumerations.GetCStringAtIndex(i).str().c_str()); } } - error.SetErrorString(error_strm.GetData()); + error.SetErrorString(error_strm.GetString()); } break; } diff --git a/lldb/source/Interpreter/OptionValueLanguage.cpp b/lldb/source/Interpreter/OptionValueLanguage.cpp index a59419f..2659762 100644 --- a/lldb/source/Interpreter/OptionValueLanguage.cpp +++ b/lldb/source/Interpreter/OptionValueLanguage.cpp @@ -61,7 +61,7 @@ Error OptionValueLanguage::SetValueFromString(llvm::StringRef value, error_strm.Printf("%s%s%s", " ", Language::GetNameForLanguageType(language), "\n"); } - error.SetErrorString(error_strm.GetData()); + error.SetErrorString(error_strm.GetString()); } } break; diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index c95876f..d26e53f 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -529,7 +529,7 @@ void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd, if (cmd->WantsRawCommandString() && !only_print_args) strm.Printf(" --"); - strm.Printf(" %s", args_str.GetData()); + strm << " " << args_str.GetString(); if (only_print_args) break; } @@ -541,7 +541,7 @@ void Options::GenerateOptionUsage(Stream &strm, CommandObject *cmd, if (!only_print_args) strm.PutChar('\n'); strm.Indent(name); - strm.Printf(" %s", arguments_str.GetData()); + strm << " " << arguments_str.GetString(); } strm.Printf("\n\n"); diff --git a/lldb/source/Interpreter/Property.cpp b/lldb/source/Interpreter/Property.cpp index b6f6507..5bac5ea 100644 --- a/lldb/source/Interpreter/Property.cpp +++ b/lldb/source/Interpreter/Property.cpp @@ -277,17 +277,17 @@ void Property::DumpDescription(CommandInterpreter &interpreter, Stream &strm, strm.EOL(); if (m_value_sp->DumpQualifiedName(qualified_name)) - strm.Printf("'%s' variables:\n\n", qualified_name.GetString().c_str()); + strm.Printf("'%s' variables:\n\n", qualified_name.GetData()); sub_properties->DumpAllDescriptions(interpreter, strm); } else { if (display_qualified_name) { StreamString qualified_name; DumpQualifiedName(qualified_name); - interpreter.OutputFormattedHelpText( - strm, qualified_name.GetString().c_str(), "--", desc, output_width); + interpreter.OutputFormattedHelpText(strm, qualified_name.GetString(), + "--", desc, output_width); } else { - interpreter.OutputFormattedHelpText(strm, m_name.GetCString(), "--", desc, - output_width); + interpreter.OutputFormattedHelpText(strm, m_name.GetStringRef(), "--", + desc, output_width); } } } diff --git a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp index d2de274..ee27a7e 100644 --- a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp @@ -1703,7 +1703,7 @@ bool ABIMacOSX_arm64::PrepareTrivialCall( for (size_t i = 0; i < args.size(); ++i) s.Printf(", arg%d = 0x%" PRIx64, static_cast(i + 1), args[i]); s.PutCString(")"); - log->PutCString(s.GetString().c_str()); + log->PutString(s.GetString()); } const uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber( diff --git a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp b/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp index 8adfe1e..5e21792 100644 --- a/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp +++ b/lldb/source/Plugins/ABI/SysV-arm64/ABISysV_arm64.cpp @@ -1706,7 +1706,7 @@ bool ABISysV_arm64::PrepareTrivialCall(Thread &thread, addr_t sp, for (size_t i = 0; i < args.size(); ++i) s.Printf(", arg%d = 0x%" PRIx64, static_cast(i + 1), args[i]); s.PutCString(")"); - log->PutCString(s.GetString().c_str()); + log->PutString(s.GetString()); } // x0 - x7 contain first 8 simple args diff --git a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp index 504267c..b97fffe 100644 --- a/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp +++ b/lldb/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp @@ -587,7 +587,7 @@ bool ABISysV_mips::PrepareTrivialCall(Thread &thread, addr_t sp, for (size_t i = 0; i < args.size(); ++i) s.Printf(", arg%zd = 0x%" PRIx64, i + 1, args[i]); s.PutCString(")"); - log->PutCString(s.GetString().c_str()); + log->PutString(s.GetString()); } RegisterContext *reg_ctx = thread.GetRegisterContext().get(); diff --git a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp index 4fe2b46..bb83dec 100644 --- a/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp +++ b/lldb/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp @@ -587,7 +587,7 @@ bool ABISysV_mips64::PrepareTrivialCall(Thread &thread, addr_t sp, for (size_t i = 0; i < args.size(); ++i) s.Printf(", arg%zd = 0x%" PRIx64, i + 1, args[i]); s.PutCString(")"); - log->PutCString(s.GetString().c_str()); + log->PutString(s.GetString()); } RegisterContext *reg_ctx = thread.GetRegisterContext().get(); diff --git a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp index 15a40e0..3e563c2 100644 --- a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp +++ b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp @@ -250,7 +250,7 @@ bool ABISysV_ppc::PrepareTrivialCall(Thread &thread, addr_t sp, s.Printf(", arg%" PRIu64 " = 0x%" PRIx64, static_cast(i + 1), args[i]); s.PutCString(")"); - log->PutCString(s.GetString().c_str()); + log->PutString(s.GetString()); } RegisterContext *reg_ctx = thread.GetRegisterContext().get(); diff --git a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp index 99fa39b..4ffcba3 100644 --- a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp +++ b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp @@ -250,7 +250,7 @@ bool ABISysV_ppc64::PrepareTrivialCall(Thread &thread, addr_t sp, s.Printf(", arg%" PRIu64 " = 0x%" PRIx64, static_cast(i + 1), args[i]); s.PutCString(")"); - log->PutCString(s.GetString().c_str()); + log->PutString(s.GetString()); } RegisterContext *reg_ctx = thread.GetRegisterContext().get(); diff --git a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp b/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp index 61f293c..7e6506b 100644 --- a/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp +++ b/lldb/source/Plugins/ABI/SysV-s390x/ABISysV_s390x.cpp @@ -232,7 +232,7 @@ bool ABISysV_s390x::PrepareTrivialCall(Thread &thread, addr_t sp, s.Printf(", arg%" PRIu64 " = 0x%" PRIx64, static_cast(i + 1), args[i]); s.PutCString(")"); - log->PutCString(s.GetString().c_str()); + log->PutString(s.GetString()); } RegisterContext *reg_ctx = thread.GetRegisterContext().get(); diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index 01681a5..2019db2 100644 --- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -1120,7 +1120,7 @@ bool ABISysV_x86_64::PrepareTrivialCall(Thread &thread, addr_t sp, s.Printf(", arg%" PRIu64 " = 0x%" PRIx64, static_cast(i + 1), args[i]); s.PutCString(")"); - log->PutCString(s.GetString().c_str()); + log->PutString(s.GetString()); } RegisterContext *reg_ctx = thread.GetRegisterContext().get(); diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp index 9d4f34f..b7415b4 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp @@ -359,7 +359,7 @@ public: } break; } - m_mnemonics.swap(mnemonic_strm.GetString()); + m_mnemonics = mnemonic_strm.GetString(); return; } else { if (m_does_branch == eLazyBoolCalculate) { @@ -834,7 +834,7 @@ public: ss.PutCString("\n"); } - log->PutCString(ss.GetData()); + log->PutString(ss.GetString()); } return true; @@ -1351,12 +1351,12 @@ const char *DisassemblerLLVMC::SymbolLookup(uint64_t value, uint64_t *type_ptr, // seen when we // have multiple levels of inlined functions at an address, only show // the first line. - std::string &str(ss.GetString()); + std::string str = ss.GetString(); size_t first_eol_char = str.find_first_of("\r\n"); if (first_eol_char != std::string::npos) { str.erase(first_eol_char); } - m_inst->AppendComment(ss.GetString()); + m_inst->AppendComment(str); } } } diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 8678f61..b18327a 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -682,7 +682,7 @@ void DynamicLoaderPOSIXDYLD::ResolveExecutableModule( if (log) log->Printf("DynamicLoaderPOSIXDYLD::%s - failed to resolve executable " "with module spec \"%s\": %s", - __FUNCTION__, stream.GetString().c_str(), error.AsCString()); + __FUNCTION__, stream.GetData(), error.AsCString()); return; } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index b55d664..0f08dd3 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -1,5 +1,4 @@ -//===-- ClangASTSource.cpp ---------------------------------------*- C++ -//-*-===// +//===-- ClangASTSource.cpp ---------------------------------------*- C++-*-===// // // The LLVM Compiler Infrastructure // @@ -1042,10 +1041,10 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) { } ss.Flush(); - if (strstr(ss.GetData(), "$__lldb")) + if (ss.GetString().contains("$__lldb")) return; // we don't need any results - ConstString selector_name(ss.GetData()); + ConstString selector_name(ss.GetString()); if (log) log->Printf("ClangASTSource::FindObjCMethodDecls[%d] on (ASTContext*)%p " @@ -1065,7 +1064,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) { StreamString ms; ms.Printf("-[%s %s]", interface_name.c_str(), selector_name.AsCString()); ms.Flush(); - ConstString instance_method_name(ms.GetData()); + ConstString instance_method_name(ms.GetString()); m_target->GetImages().FindFunctions( instance_method_name, lldb::eFunctionNameTypeFull, include_symbols, @@ -1077,7 +1076,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) { ms.Clear(); ms.Printf("+[%s %s]", interface_name.c_str(), selector_name.AsCString()); ms.Flush(); - ConstString class_method_name(ms.GetData()); + ConstString class_method_name(ms.GetString()); m_target->GetImages().FindFunctions( class_method_name, lldb::eFunctionNameTypeFull, include_symbols, diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index d91da5f..a75e60f 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -135,7 +135,7 @@ public: bool hasErrors() { return m_has_errors; } - const std::string &getErrorString() { return m_error_stream.GetString(); } + llvm::StringRef getErrorString() { return m_error_stream.GetString(); } }; class ClangDiagnosticManagerAdapter : public clang::DiagnosticConsumer { @@ -627,7 +627,7 @@ unsigned ClangExpressionParser::Parse(DiagnosticManager &diagnostic_manager) { diagnostic_manager.PutString(eDiagnosticSeverityError, "while importing modules:"); diagnostic_manager.AppendMessageToDiagnostic( - m_pp_callbacks->getErrorString().c_str()); + m_pp_callbacks->getErrorString()); } if (!num_errors) { diff --git a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp index f453696..9ceeb76 100644 --- a/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp +++ b/lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp @@ -323,7 +323,7 @@ bool EmulationStateARM::LoadStateFromDictionary( for (int i = 0; i < 16; ++i) { sstr.Clear(); sstr.Printf("r%d", i); - ConstString reg_name(sstr.GetData()); + ConstString reg_name(sstr.GetString()); value_sp = reg_dict->GetValueForKey(reg_name); if (value_sp.get() == NULL) return false; @@ -341,7 +341,7 @@ bool EmulationStateARM::LoadStateFromDictionary( for (int i = 0; i < 32; ++i) { sstr.Clear(); sstr.Printf("s%d", i); - ConstString reg_name(sstr.GetData()); + ConstString reg_name(sstr.GetString()); value_sp = reg_dict->GetValueForKey(reg_name); if (value_sp.get() == NULL) return false; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index a0b2304..82f1a5d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -153,8 +153,8 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex( StreamString name; name.Printf("[%" PRIu64 "]", (uint64_t)idx); ValueObjectSP retval_sp(CreateValueObjectFromData( - name.GetData(), DataExtractor(buffer_sp, process_sp->GetByteOrder(), - process_sp->GetAddressByteSize()), + name.GetString(), DataExtractor(buffer_sp, process_sp->GetByteOrder(), + process_sp->GetAddressByteSize()), m_exe_ctx_ref, m_bool_type)); if (retval_sp) m_children[idx] = retval_sp; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp index d7cab15..b7aa70c 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxInitializerList.cpp @@ -83,7 +83,7 @@ lldb::ValueObjectSP lldb_private::formatters:: offset = offset + m_start->GetValueAsUnsigned(0); StreamString name; name.Printf("[%" PRIu64 "]", (uint64_t)idx); - return CreateValueObjectFromAddress(name.GetData(), offset, + return CreateValueObjectFromAddress(name.GetString(), offset, m_backend.GetExecutionContextRef(), m_element_type); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp index eb42b44..16bd631 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp @@ -298,8 +298,9 @@ lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::GetChildAtIndex( StreamString name; name.Printf("[%" PRIu64 "]", (uint64_t)idx); - return CreateValueObjectFromData( - name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type); + return CreateValueObjectFromData(name.GetString(), data, + m_backend.GetExecutionContextRef(), + m_element_type); } bool lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::Update() { diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp index cd0855a..e8fcd0f 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp @@ -399,7 +399,8 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex( StreamString name; name.Printf("[%" PRIu64 "]", (uint64_t)idx); auto potential_child_sp = CreateValueObjectFromData( - name.GetData(), data, m_backend.GetExecutionContextRef(), m_element_type); + name.GetString(), data, m_backend.GetExecutionContextRef(), + m_element_type); if (potential_child_sp) { switch (potential_child_sp->GetNumChildren()) { case 1: { @@ -417,7 +418,7 @@ lldb_private::formatters::LibcxxStdMapSyntheticFrontEnd::GetChildAtIndex( break; } } - potential_child_sp->SetName(ConstString(name.GetData())); + potential_child_sp->SetName(ConstString(name.GetString())); } m_iterators[idx] = iterator; return potential_child_sp; diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index fa3cd74..5fe4b3a 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -139,7 +139,7 @@ lldb::ValueObjectSP lldb_private::formatters:: const bool thread_and_frame_only_if_stopped = true; ExecutionContext exe_ctx = val_hash.first->GetExecutionContextRef().Lock( thread_and_frame_only_if_stopped); - return CreateValueObjectFromData(stream.GetData(), data, exe_ctx, + return CreateValueObjectFromData(stream.GetString(), data, exe_ctx, val_hash.first->GetCompilerType()); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp index 950dcee..b5c9b6d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxVector.cpp @@ -93,7 +93,7 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::GetChildAtIndex( offset = offset + m_start->GetValueAsUnsigned(0); StreamString name; name.Printf("[%" PRIu64 "]", (uint64_t)idx); - return CreateValueObjectFromAddress(name.GetData(), offset, + return CreateValueObjectFromAddress(name.GetString(), offset, m_backend.GetExecutionContextRef(), m_element_type); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp index d5fd386..c4a6e3d 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp @@ -73,7 +73,7 @@ bool LibStdcppTupleSyntheticFrontEnd::Update() { if (value_sp) { StreamString name; name.Printf("[%zd]", m_members.size()); - value_sp->SetName(ConstString(name.GetData())); + value_sp->SetName(ConstString(name.GetString())); m_members.push_back(value_sp); } diff --git a/lldb/source/Plugins/Language/Go/GoFormatterFunctions.cpp b/lldb/source/Plugins/Language/Go/GoFormatterFunctions.cpp index 110fc63..0f78f64 100644 --- a/lldb/source/Plugins/Language/Go/GoFormatterFunctions.cpp +++ b/lldb/source/Plugins/Language/Go/GoFormatterFunctions.cpp @@ -42,7 +42,7 @@ public: lldb::addr_t object_at_idx = m_base_data_address; object_at_idx += idx * m_type.GetByteSize(nullptr); cached = CreateValueObjectFromAddress( - idx_name.GetData(), object_at_idx, + idx_name.GetString(), object_at_idx, m_backend.GetExecutionContextRef(), m_type); } return cached; diff --git a/lldb/source/Plugins/Language/Java/JavaFormatterFunctions.cpp b/lldb/source/Plugins/Language/Java/JavaFormatterFunctions.cpp index 8ee8ef5..286651a 100644 --- a/lldb/source/Plugins/Language/Java/JavaFormatterFunctions.cpp +++ b/lldb/source/Plugins/Language/Java/JavaFormatterFunctions.cpp @@ -70,7 +70,7 @@ public: DataExtractor data(buffer_sp, process_sp->GetByteOrder(), process_sp->GetAddressByteSize()); return CreateValueObjectFromData( - name.GetData(), data, valobj->GetExecutionContextRef(), element_type); + name.GetString(), data, valobj->GetExecutionContextRef(), element_type); } bool Update() override { return false; } diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp b/lldb/source/Plugins/Language/ObjC/NSArray.cpp index 034687b..6ab6d53 100644 --- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp @@ -350,7 +350,7 @@ lldb_private::formatters::NSArrayMSyntheticFrontEnd::GetChildAtIndex( object_at_idx += (pyhs_idx * m_ptr_size); StreamString idx_name; idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx); - return CreateValueObjectFromAddress(idx_name.GetData(), object_at_idx, + return CreateValueObjectFromAddress(idx_name.GetString(), object_at_idx, m_exe_ctx_ref, m_id_type); } @@ -571,7 +571,7 @@ lldb_private::formatters::NSArrayISyntheticFrontEnd::GetChildAtIndex( return lldb::ValueObjectSP(); StreamString idx_name; idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx); - return CreateValueObjectFromAddress(idx_name.GetData(), object_at_idx, + return CreateValueObjectFromAddress(idx_name.GetString(), object_at_idx, m_exe_ctx_ref, m_id_type); } diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp index 022a471..5cc52c8 100644 --- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp @@ -499,7 +499,7 @@ lldb_private::formatters::NSDictionaryISyntheticFrontEnd::GetChildAtIndex( StreamString idx_name; idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx); DataExtractor data(buffer_sp, m_order, m_ptr_size); - dict_item.valobj_sp = CreateValueObjectFromData(idx_name.GetData(), data, + dict_item.valobj_sp = CreateValueObjectFromData(idx_name.GetString(), data, m_exe_ctx_ref, m_pair_type); } return dict_item.valobj_sp; @@ -729,7 +729,7 @@ lldb_private::formatters::NSDictionaryMSyntheticFrontEnd::GetChildAtIndex( StreamString idx_name; idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx); DataExtractor data(buffer_sp, m_order, m_ptr_size); - dict_item.valobj_sp = CreateValueObjectFromData(idx_name.GetData(), data, + dict_item.valobj_sp = CreateValueObjectFromData(idx_name.GetString(), data, m_exe_ctx_ref, m_pair_type); } return dict_item.valobj_sp; diff --git a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp index d169334..9533e96 100644 --- a/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSIndexPath.cpp @@ -210,8 +210,8 @@ protected: StreamString idx_name; idx_name.Printf("[%" PRIu64 "]", (uint64_t)idx); - return ValueObjectConstResult::Create(m_process, v, - ConstString(idx_name.GetData())); + return ValueObjectConstResult::Create( + m_process, v, ConstString(idx_name.GetString())); } void Clear() { diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp b/lldb/source/Plugins/Language/ObjC/NSSet.cpp index a9ca98c..9757c58 100644 --- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp @@ -435,7 +435,7 @@ lldb_private::formatters::NSSetISyntheticFrontEnd::GetChildAtIndex(size_t idx) { process_sp->GetAddressByteSize()); set_item.valobj_sp = CreateValueObjectFromData( - idx_name.GetData(), data, m_exe_ctx_ref, + idx_name.GetString(), data, m_exe_ctx_ref, m_backend.GetCompilerType().GetBasicTypeFromAST( lldb::eBasicTypeObjCID)); } @@ -586,7 +586,7 @@ lldb_private::formatters::NSSetMSyntheticFrontEnd::GetChildAtIndex(size_t idx) { process_sp->GetAddressByteSize()); set_item.valobj_sp = CreateValueObjectFromData( - idx_name.GetData(), data, m_exe_ctx_ref, + idx_name.GetString(), data, m_exe_ctx_ref, m_backend.GetCompilerType().GetBasicTypeFromAST( lldb::eBasicTypeObjCID)); } diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index 526ace1..6e59a8b 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -217,7 +217,7 @@ ConstString ObjCLanguage::MethodName::GetFullNameWithoutCategory( strm.PutChar('-'); strm.Printf("[%s %s]", GetClassName().GetCString(), GetSelector().GetCString()); - return ConstString(strm.GetString().c_str()); + return ConstString(strm.GetString()); } if (!empty_if_no_category) { @@ -242,25 +242,25 @@ size_t ObjCLanguage::MethodName::GetFullNames(std::vector &names, if (category) { strm.Printf("%c[%s %s]", is_class_method ? '+' : '-', GetClassName().GetCString(), GetSelector().GetCString()); - names.push_back(ConstString(strm.GetString().c_str())); + names.emplace_back(strm.GetString()); } } else { const ConstString &class_name = GetClassName(); const ConstString &selector = GetSelector(); strm.Printf("+[%s %s]", class_name.GetCString(), selector.GetCString()); - names.push_back(ConstString(strm.GetString().c_str())); + names.emplace_back(strm.GetString()); strm.Clear(); strm.Printf("-[%s %s]", class_name.GetCString(), selector.GetCString()); - names.push_back(ConstString(strm.GetString().c_str())); + names.emplace_back(strm.GetString()); strm.Clear(); if (category) { strm.Printf("+[%s(%s) %s]", class_name.GetCString(), category.GetCString(), selector.GetCString()); - names.push_back(ConstString(strm.GetString().c_str())); + names.emplace_back(strm.GetString()); strm.Clear(); strm.Printf("-[%s(%s) %s]", class_name.GetCString(), category.GetCString(), selector.GetCString()); - names.push_back(ConstString(strm.GetString().c_str())); + names.emplace_back(strm.GetString()); } } } diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp index ce78d4d..16619a7 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTypeEncodingParser.cpp @@ -147,7 +147,7 @@ clang::QualType AppleObjCTypeEncodingParser::BuildAggregate( if (element.name.empty()) { StreamString elem_name; elem_name.Printf("__unnamed_%u", count); - element.name = std::string(elem_name.GetData()); + element.name = elem_name.GetString(); } ClangASTContext::AddFieldToRecordType( union_type, element.name.c_str(), diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp index 8b83f82..82473fb 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp @@ -1566,7 +1566,7 @@ void RenderScriptRuntime::CaptureScriptInit(RuntimeHook *hook, script->type = ScriptDetails::eScriptC; script->cache_dir = cache_dir; script->res_name = res_name; - script->shared_lib = strm.GetData(); + script->shared_lib = strm.GetString(); script->context = addr_t(args[eRsContext]); } diff --git a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp index f91ed43..620e839 100644 --- a/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp +++ b/lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp @@ -184,7 +184,7 @@ HistoryThreads MemoryHistoryASan::GetHistoryThreads(lldb::addr_t address) { options.SetLanguage(eLanguageTypeObjC_plus_plus); ExpressionResults expr_result = UserExpression::Evaluate( - exe_ctx, options, expr.GetData(), "", return_value_sp, eval_error); + exe_ctx, options, expr.GetString(), "", return_value_sp, eval_error); if (expr_result != eExpressionCompleted) { process_sp->GetTarget().GetDebugger().GetAsyncOutputStream()->Printf( "Warning: Cannot evaluate AddressSanitizer expression:\n%s\n", diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 45d3b12..9ef4e9c 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -5996,7 +5996,8 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp, const size_t LC_THREAD_data_size = LC_THREAD_data.GetSize(); buffer.PutHex32(LC_THREAD); buffer.PutHex32(8 + LC_THREAD_data_size); // cmd + cmdsize + data - buffer.Write(LC_THREAD_data.GetData(), LC_THREAD_data_size); + buffer.Write(LC_THREAD_data.GetString().data(), + LC_THREAD_data_size); } // Write out all of the segment load commands diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index d253800..69826a0 100644 --- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -1,5 +1,4 @@ -//===-- OperatingSystemPython.cpp --------------------------------*- C++ -//-*-===// +//===-- OperatingSystemPython.cpp --------------------------------*- C++-*-===// // // The LLVM Compiler Infrastructure // @@ -197,7 +196,7 @@ bool OperatingSystemPython::UpdateThreadList(ThreadList &old_thread_list, if (log) { StreamString strm; threads_list->Dump(strm); - log->Printf("threads_list = %s", strm.GetString().c_str()); + log->Printf("threads_list = %s", strm.GetData()); } const uint32_t num_threads = threads_list->GetSize(); diff --git a/lldb/source/Plugins/Platform/Android/AdbClient.cpp b/lldb/source/Plugins/Platform/Android/AdbClient.cpp index 79ad8f5..7c9c70a 100644 --- a/lldb/source/Plugins/Platform/Android/AdbClient.cpp +++ b/lldb/source/Plugins/Platform/Android/AdbClient.cpp @@ -360,7 +360,7 @@ Error AdbClient::internalShell(const char *command, uint32_t timeout_ms, StreamString adb_command; adb_command.Printf("shell:%s", command); - error = SendMessage(adb_command.GetData(), false); + error = SendMessage(adb_command.GetString(), false); if (error.Fail()) return error; diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp index a870929..9a6a375 100644 --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -227,7 +227,7 @@ Error PlatformFreeBSD::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetData()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", diff --git a/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp b/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp index 69f5c29..ac3fe6e 100644 --- a/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp +++ b/lldb/source/Plugins/Platform/Kalimba/PlatformKalimba.cpp @@ -163,7 +163,7 @@ Error PlatformKalimba::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetData()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index 5b6bc35..8c2b370 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -317,7 +317,7 @@ Error PlatformLinux::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetData()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", @@ -633,7 +633,7 @@ PlatformLinux::DebugProcess(ProcessLaunchInfo &launch_info, Debugger &debugger, const FileAction *file_action; while ((file_action = launch_info.GetFileActionAtIndex(i++)) != nullptr) { file_action->Dump(stream); - log->PutCString(stream.GetString().c_str()); + log->PutCString(stream.GetData()); stream.Clear(); } } @@ -713,5 +713,5 @@ ConstString PlatformLinux::GetFullNameForDylib(ConstString basename) { StreamString stream; stream.Printf("lib%s.so", basename.GetCString()); - return ConstString(stream.GetData()); + return ConstString(stream.GetString()); } diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp index b5ab04c..968ce5f 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp @@ -230,7 +230,7 @@ Error PlatformAppleTVSimulator::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetString().str().c_str()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp index 15d7e0c..291f586 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp @@ -232,7 +232,7 @@ Error PlatformAppleWatchSimulator::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetString().str().c_str()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index a92a8da..1849120 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -133,8 +133,8 @@ FileSpecList PlatformDarwin::LocateExecutableScriptingResources( "%s/../Python/%s.py", symfile_spec.GetDirectory().GetCString(), original_module_basename.c_str()); - FileSpec script_fspec(path_string.GetData(), true); - FileSpec orig_script_fspec(original_path_string.GetData(), + FileSpec script_fspec(path_string.GetString(), true); + FileSpec orig_script_fspec(original_path_string.GetString(), true); // if we did some replacements of reserved characters, and a @@ -295,7 +295,7 @@ Error PlatformDarwin::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetData()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", @@ -1779,7 +1779,7 @@ ConstString PlatformDarwin::GetFullNameForDylib(ConstString basename) { StreamString stream; stream.Printf("lib%s.dylib", basename.GetCString()); - return ConstString(stream.GetData()); + return ConstString(stream.GetString()); } bool PlatformDarwin::GetOSVersion(uint32_t &major, uint32_t &minor, diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp index 89b61bf..0e7df95 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -222,13 +222,13 @@ ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) { versions[1]); fspec.SetFile(sdk_path.GetString(), false); if (fspec.Exists()) - return ConstString(sdk_path.GetString().c_str()); + return ConstString(sdk_path.GetString()); } if (!default_xcode_sdk.empty()) { fspec.SetFile(default_xcode_sdk, false); if (fspec.Exists()) - return ConstString(default_xcode_sdk.c_str()); + return ConstString(default_xcode_sdk); } } } diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp index 5b09da2..47b1c8f 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp @@ -232,7 +232,7 @@ Error PlatformRemoteAppleTV::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetData()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp index c3e9ac5..f12fcab 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp @@ -242,7 +242,7 @@ Error PlatformRemoteAppleWatch::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetData()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp index ec88851..cf4f88d 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -237,7 +237,7 @@ Error PlatformRemoteiOS::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetData()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp index ff73265d..b4ce083 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp @@ -236,7 +236,7 @@ Error PlatformiOSSimulator::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetString().str().c_str()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp index cb3c124..6ae6252 100644 --- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -219,7 +219,7 @@ Error PlatformNetBSD::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetData()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp index b751de7..482e183 100644 --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -435,7 +435,7 @@ std::string PlatformPOSIX::GetPlatformSpecificConnectionInformation() { if (GetLocalCacheDirectory() && *GetLocalCacheDirectory()) stream.Printf("cache dir: %s", GetLocalCacheDirectory()); if (stream.GetSize()) - return stream.GetData(); + return stream.GetString(); else return ""; } diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp index d25bb7b..f16ebc4 100644 --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -265,7 +265,7 @@ Error PlatformWindows::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetData()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", @@ -603,5 +603,5 @@ ConstString PlatformWindows::GetFullNameForDylib(ConstString basename) { StreamString stream; stream.Printf("%s.dll", basename.GetCString()); - return ConstString(stream.GetData()); + return ConstString(stream.GetString()); } diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp index 8b9972f..1a5df93 100644 --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -147,7 +147,7 @@ Error PlatformRemoteGDBServer::ResolveExecutable( error.SetErrorStringWithFormat( "'%s' doesn't contain any '%s' platform architectures: %s", resolved_module_spec.GetFileSpec().GetPath().c_str(), - GetPluginName().GetCString(), arch_names.GetString().c_str()); + GetPluginName().GetCString(), arch_names.GetData()); } else { error.SetErrorStringWithFormat( "'%s' is not readable", @@ -185,7 +185,7 @@ bool PlatformRemoteGDBServer::GetModuleSpec(const FileSpec &module_file_spec, log->Printf( "PlatformRemoteGDBServer::%s - got module info for (%s:%s) : %s", __FUNCTION__, module_path.c_str(), arch.GetTriple().getTriple().c_str(), - stream.GetString().c_str()); + stream.GetData()); } return true; diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index 77b9fc8..e3842e1 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -965,7 +965,7 @@ public: packet.PutBytesAsRawHex8( reply.GetDataStart(), reply.GetByteSize(), endian::InlHostByteOrder(), endian::InlHostByteOrder()); - result.AppendMessage(packet.GetString().c_str()); + result.AppendMessage(packet.GetString()); result.SetStatus(eReturnStatusSuccessFinishResult); return true; } else { diff --git a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp index 50fc0c20..3c33ddb 100644 --- a/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp +++ b/lldb/source/Plugins/Process/Utility/RegisterContextLLDB.cpp @@ -218,7 +218,7 @@ void RegisterContextLLDB::InitializeZerothFrame() { StreamString active_row_strm; active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(), &m_thread, m_start_pc.GetLoadAddress(exe_ctx.GetTargetPtr())); - UnwindLogMsg("%s", active_row_strm.GetString().c_str()); + UnwindLogMsg("%s", active_row_strm.GetData()); } } @@ -564,7 +564,7 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { StreamString active_row_strm; active_row->Dump(active_row_strm, m_fast_unwind_plan_sp.get(), &m_thread, m_start_pc.GetLoadAddress(exe_ctx.GetTargetPtr())); - UnwindLogMsg("active row: %s", active_row_strm.GetString().c_str()); + UnwindLogMsg("active row: %s", active_row_strm.GetData()); } } else { m_full_unwind_plan_sp = GetFullUnwindPlanForFrame(); @@ -577,7 +577,7 @@ void RegisterContextLLDB::InitializeNonZerothFrame() { active_row->Dump(active_row_strm, m_full_unwind_plan_sp.get(), &m_thread, m_start_pc.GetLoadAddress(exe_ctx.GetTargetPtr())); - UnwindLogMsg("active row: %s", active_row_strm.GetString().c_str()); + UnwindLogMsg("active row: %s", active_row_strm.GetData()); } } } diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp index 2afed11..3b29a18 100644 --- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp +++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp @@ -306,7 +306,7 @@ const char *StopInfoMachException::GetDescription() { if (m_exc_data_count > 0) strm.PutChar(')'); - m_description.swap(strm.GetString()); + m_description = strm.GetString(); } return m_description.c_str(); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp index 6019428..19fc78d 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -200,7 +200,9 @@ GDBRemoteCommunication::SendPacketNoLock(llvm::StringRef payload) { Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS)); ConnectionStatus status = eConnectionStatusSuccess; - const char *packet_data = packet.GetData(); + // TODO: Don't shimmy through a std::string, just use StringRef. + std::string packet_str = packet.GetString(); + const char *packet_data = packet_str.c_str(); const size_t packet_length = packet.GetSize(); size_t bytes_written = Write(packet_data, packet_length, status, NULL); if (log) { @@ -236,7 +238,7 @@ GDBRemoteCommunication::SendPacketNoLock(llvm::StringRef payload) { strm.Printf("\\x%2.2x", *p); // Print the checksum strm.Printf("%*s", (int)3, p); - log->PutCString(strm.GetString().c_str()); + log->PutString(strm.GetString()); } else log->Printf("<%4" PRIu64 "> send packet: %.*s", (uint64_t)bytes_written, (int)packet_length, packet_data); @@ -867,7 +869,7 @@ GDBRemoteCommunication::CheckForPacket(const uint8_t *src, size_t src_len, // Packet footer... strm.Printf("%c%c%c", m_bytes[total_length - 3], m_bytes[total_length - 2], m_bytes[total_length - 1]); - log->PutCString(strm.GetString().c_str()); + log->PutString(strm.GetString()); } else { if (CompressionIsEnabled()) log->Printf("<%4" PRIu64 ":%" PRIu64 "> read packet: %.*s", @@ -1250,7 +1252,7 @@ Error GDBRemoteCommunication::StartDebugserverProcess( Platform *const platform = nullptr; launch_info.Dump(string_stream, platform); log->Printf("launch info for gdb-remote stub:\n%s", - string_stream.GetString().c_str()); + string_stream.GetData()); } error = Host::LaunchProcess(launch_info); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 49733a5..1e5067a 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -349,7 +349,7 @@ void GDBRemoteCommunicationClient::GetRemoteQSupported() { } StringExtractorGDBRemote response; - if (SendPacketAndWaitForResponse(packet.GetData(), response, + if (SendPacketAndWaitForResponse(packet.GetString(), response, /*send_async=*/false) == PacketResult::Success) { const char *response_cstr = response.GetStringRef().c_str(); @@ -518,7 +518,7 @@ GDBRemoteCommunicationClient::SendThreadSpecificPacketAndWaitForResponse( GDBR_LOG_PROCESS | GDBR_LOG_PACKETS)) log->Printf("GDBRemoteCommunicationClient::%s: Didn't get sequence mutex " "for %s packet.", - __FUNCTION__, payload.GetString().c_str()); + __FUNCTION__, payload.GetData()); return PacketResult::ErrorNoSequenceLock; } @@ -2685,15 +2685,15 @@ Error GDBRemoteCommunicationClient::MakeDirectory(const FileSpec &file_spec, stream.PutHex32(file_permissions); stream.PutChar(','); stream.PutCStringAsRawHex8(path.c_str()); - const char *packet = stream.GetData(); + llvm::StringRef packet = stream.GetString(); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(packet, response, false) != PacketResult::Success) - return Error("failed to send '%s' packet", packet); + return Error("failed to send '%s' packet", packet.str().c_str()); if (response.GetChar() != 'F') - return Error("invalid response to '%s' packet", packet); + return Error("invalid response to '%s' packet", packet.str().c_str()); return Error(response.GetU32(UINT32_MAX), eErrorTypePOSIX); } @@ -2706,15 +2706,15 @@ Error GDBRemoteCommunicationClient::SetFilePermissions( stream.PutHex32(file_permissions); stream.PutChar(','); stream.PutCStringAsRawHex8(path.c_str()); - const char *packet = stream.GetData(); + llvm::StringRef packet = stream.GetString(); StringExtractorGDBRemote response; if (SendPacketAndWaitForResponse(packet, response, false) != PacketResult::Success) - return Error("failed to send '%s' packet", packet); + return Error("failed to send '%s' packet", stream.GetData()); if (response.GetChar() != 'F') - return Error("invalid response to '%s' packet", packet); + return Error("invalid response to '%s' packet", stream.GetData()); return Error(response.GetU32(UINT32_MAX), eErrorTypePOSIX); } @@ -2800,7 +2800,7 @@ Error GDBRemoteCommunicationClient::GetFilePermissions( PacketResult::Success) { if (response.GetChar() != 'F') { error.SetErrorStringWithFormat("invalid response to '%s' packet", - stream.GetString().c_str()); + stream.GetData()); } else { const uint32_t mode = response.GetS32(-1); if (static_cast(mode) == -1) { @@ -2818,7 +2818,7 @@ Error GDBRemoteCommunicationClient::GetFilePermissions( } } else { error.SetErrorStringWithFormat("failed to send '%s' packet", - stream.GetString().c_str()); + stream.GetData()); } return error; } @@ -3258,7 +3258,7 @@ GDBRemoteCommunicationClient::GetModulesInfo( unescaped_payload.PutCString("jModulesInfo:"); module_array_sp->Write(unescaped_payload); StreamGDBRemote payload; - payload.PutEscapedBytes(unescaped_payload.GetData(), + payload.PutEscapedBytes(unescaped_payload.GetString().data(), unescaped_payload.GetSize()); StringExtractorGDBRemote response; @@ -3569,7 +3569,7 @@ GDBRemoteCommunicationClient::GetSupportedStructuredDataPlugins() { m_supported_async_json_packets_sp->Dump(stream); log->Printf("GDBRemoteCommunicationClient::%s(): supported async " "JSON packets: %s", - __FUNCTION__, stream.GetString().c_str()); + __FUNCTION__, stream.GetData()); } } @@ -3600,7 +3600,7 @@ Error GDBRemoteCommunicationClient::ConfigureRemoteStructuredData( unescaped_stream.Flush(); // Add it to the stream in escaped fashion. - stream.PutEscapedBytes(unescaped_stream.GetData(), + stream.PutEscapedBytes(unescaped_stream.GetString().data(), unescaped_stream.GetSize()); } stream.Flush(); diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp index 28d94f8..e4e6810f6 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp @@ -1174,7 +1174,8 @@ GDBRemoteCommunicationServerCommon::Handle_jModulesInfo( StreamString response; response_array_sp->Write(response); StreamGDBRemote escaped_response; - escaped_response.PutEscapedBytes(response.GetData(), response.GetSize()); + escaped_response.PutEscapedBytes(response.GetString().data(), + response.GetSize()); return SendPacketNoLock(escaped_response.GetString()); } diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp index 33b60b5..8bf48e9 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp @@ -246,7 +246,8 @@ GDBRemoteCommunicationServerPlatform::Handle_qQueryGDBServer( server_list.Write(response); StreamGDBRemote escaped_response; - escaped_response.PutEscapedBytes(response.GetData(), response.GetSize()); + escaped_response.PutEscapedBytes(response.GetString().data(), + response.GetSize()); return SendPacketNoLock(escaped_response.GetString()); } diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index c0fbccb..3761f06 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -1226,7 +1226,7 @@ Error ProcessGDBRemote::DoAttachToProcessWithName( m_async_broadcaster.BroadcastEvent( eBroadcastBitAsyncContinue, - new EventDataBytes(packet.GetData(), packet.GetSize())); + new EventDataBytes(packet.GetString().data(), packet.GetSize())); } else SetExitStatus(-1, error.AsCString()); @@ -1330,7 +1330,7 @@ Error ProcessGDBRemote::DoResume() { } if (continue_packet_error) - continue_packet.GetString().clear(); + continue_packet.Clear(); } } else continue_packet_error = true; @@ -1455,7 +1455,7 @@ Error ProcessGDBRemote::DoResume() { m_async_broadcaster.BroadcastEvent( eBroadcastBitAsyncContinue, - new EventDataBytes(continue_packet.GetData(), + new EventDataBytes(continue_packet.GetString().data(), continue_packet.GetSize())); if (listener_sp->WaitForEvent(std::chrono::seconds(5), event_sp) == @@ -2812,10 +2812,10 @@ size_t ProcessGDBRemote::DoWriteMemory(addr_t addr, const void *buf, else error.SetErrorStringWithFormat( "unexpected response to GDB server memory write packet '%s': '%s'", - packet.GetString().c_str(), response.GetStringRef().c_str()); + packet.GetData(), response.GetStringRef().c_str()); } else { error.SetErrorStringWithFormat("failed to send packet: '%s'", - packet.GetString().c_str()); + packet.GetData()); } return 0; } @@ -4043,8 +4043,7 @@ bool ProcessGDBRemote::GetModuleSpec(const FileSpec &module_file_spec, module_spec.Dump(stream); log->Printf("ProcessGDBRemote::%s - got module info for (%s:%s) : %s", __FUNCTION__, module_file_spec.GetPath().c_str(), - arch.GetTriple().getTriple().c_str(), - stream.GetString().c_str()); + arch.GetTriple().getTriple().c_str(), stream.GetData()); } m_cached_module_specs[key] = module_spec; @@ -4836,7 +4835,7 @@ ParseStructuredDataPacket(llvm::StringRef packet) { json_str.Flush(); log->Printf("ProcessGDBRemote::%s() " "received Async StructuredData packet: %s", - __FUNCTION__, json_str.GetString().c_str()); + __FUNCTION__, json_str.GetData()); } else { log->Printf("ProcessGDBRemote::%s" "() received StructuredData packet:" @@ -5083,7 +5082,7 @@ public: packet.GetString(), response, send_async); result.SetStatus(eReturnStatusSuccessFinishResult); Stream &output_strm = result.GetOutputStream(); - output_strm.Printf(" packet: %s\n", packet.GetString().c_str()); + output_strm.Printf(" packet: %s\n", packet.GetData()); const std::string &response_str = response.GetStringRef(); if (response_str.empty()) diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index d4485cc..3747b2b 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1438,7 +1438,7 @@ bool ScriptInterpreterPython::GenerateTypeSynthClass(StringList &user_input, // Create the function name & definition string. sstr.Printf("class %s:", auto_generated_class_name.c_str()); - auto_generated_class.AppendString(sstr.GetData()); + auto_generated_class.AppendString(sstr.GetString()); // Wrap everything up inside the class, increasing the indentation. // we don't need to play any fancy indentation tricks here because there is no @@ -1446,7 +1446,7 @@ bool ScriptInterpreterPython::GenerateTypeSynthClass(StringList &user_input, for (int i = 0; i < num_lines; ++i) { sstr.Clear(); sstr.Printf(" %s", user_input.GetStringAtIndex(i)); - auto_generated_class.AppendString(sstr.GetData()); + auto_generated_class.AppendString(sstr.GetString()); } // Verify that the results are valid Python. @@ -2873,7 +2873,7 @@ bool ScriptInterpreterPython::GetDocumentationForItem(const char *item, StreamString str_stream; str_stream.Printf( "Function %s was not found. Containing module might be missing.", item); - dest.assign(str_stream.GetData()); + dest = str_stream.GetString(); return false; } } diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp index 63bfc33..2d2705c 100644 --- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -796,7 +796,7 @@ protected: " the property and relaunch the target binary to have" " these messages excluded.", source_name, source_name); - result.AppendWarning(stream.GetString().c_str()); + result.AppendWarning(stream.GetString()); } bool DoExecute(Args &command, CommandReturnObject &result) override { @@ -1107,7 +1107,7 @@ bool RunEnableCommand(CommandInterpreter &interpreter) { // Run the command. CommandReturnObject return_object; - interpreter.HandleCommand(command_stream.GetString().c_str(), eLazyBoolNo, + interpreter.HandleCommand(command_stream.GetData(), eLazyBoolNo, return_object); return return_object.Succeeded(); } @@ -1173,7 +1173,7 @@ void StructuredDataDarwinLog::HandleArrivalOfStructuredData( else json_stream.PutCString(""); log->Printf("StructuredDataDarwinLog::%s() called with json: %s", - __FUNCTION__, json_stream.GetString().c_str()); + __FUNCTION__, json_stream.GetData()); } // Ignore empty structured data. @@ -1222,8 +1222,7 @@ static void SetErrorWithJSON(Error &error, const char *message, object.Dump(object_stream); object_stream.Flush(); - error.SetErrorStringWithFormat("%s: %s", message, - object_stream.GetString().c_str()); + error.SetErrorStringWithFormat("%s: %s", message, object_stream.GetData()); } Error StructuredDataDarwinLog::GetDescription( @@ -1862,10 +1861,9 @@ StructuredDataDarwinLog::DumpHeader(Stream &output_stream, } stream.PutCString("] "); - auto &result = stream.GetString(); - output_stream.PutCString(result); + output_stream.PutCString(stream.GetString()); - return result.size(); + return stream.GetSize(); } size_t StructuredDataDarwinLog::HandleDisplayOfEvent( diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 44ff9cc9..c5a62d5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -2601,7 +2601,7 @@ Function *DWARFASTParserClang::ParseFunctionFromDWARF(const SymbolContext &sc, if (type_quals & clang::Qualifiers::Const) sstr << " const"; - func_name.SetValue(ConstString(sstr.GetData()), false); + func_name.SetValue(ConstString(sstr.GetString()), false); } else func_name.SetValue(ConstString(name), false); @@ -2815,7 +2815,7 @@ bool DWARFASTParserClang::ParseChildMembers( ss.Printf("set%c%s:", toupper(prop_name[0]), &prop_name[1]); - fixed_setter.SetCString(ss.GetData()); + fixed_setter.SetString(ss.GetString()); prop_setter_name = fixed_setter.GetCString(); } } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index 66dee4b..6d3ff8e 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -265,7 +265,7 @@ size_t DWARFCompileUnit::ExtractDIEsIfNeeded(bool cu_die_only) { strm.Printf("error: no DIE for compile unit"); else m_die_array[0].Dump(m_dwarf2Data, this, strm, UINT32_MAX); - verbose_log->PutCString(strm.GetString().c_str()); + verbose_log->PutString(strm.GetString()); } if (!m_dwo_symbol_file) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index d82b3d4..3927745 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3918,7 +3918,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc, NULL); GetObjectFile()->GetModule()->ReportError( "0x%8.8x: %s has an invalid location: %s", die.GetOffset(), - die.GetTagAsCString(), strm.GetString().c_str()); + die.GetTagAsCString(), strm.GetData()); } } SymbolFileDWARFDebugMap *debug_map_symfile = GetDebugMapSymfile(); diff --git a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp index 40a3d27..0852f19 100644 --- a/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp +++ b/lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp @@ -1,5 +1,4 @@ -//===-- UnwindAssemblyInstEmulation.cpp --------------------------*- C++ -//-*-===// +//===-- UnwindAssemblyInstEmulation.cpp --------------------------*- C++-*-===// // // The LLVM Compiler Infrastructure // @@ -221,7 +220,7 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly( FormatEntity::Parse("${frame.pc}: ", format); inst->Dump(&strm, inst_list.GetMaxOpcocdeByteSize(), show_address, show_bytes, NULL, NULL, NULL, &format, 0); - log->PutCString(strm.GetData()); + log->PutString(strm.GetString()); } last_condition = m_inst_emulator_ap->GetInstructionCondition(); @@ -276,7 +275,7 @@ bool UnwindAssemblyInstEmulation::GetNonCallSiteUnwindPlanFromAssembly( strm.Printf("Resulting unwind rows for [0x%" PRIx64 " - 0x%" PRIx64 "):", base_addr, base_addr + range.GetByteSize()); unwind_plan.Dump(strm, nullptr, base_addr); - log->PutCString(strm.GetData()); + log->PutString(strm.GetString()); } return unwind_plan.GetRowCount() > 0; } @@ -380,7 +379,7 @@ size_t UnwindAssemblyInstEmulation::ReadMemory( ", dst = %p, dst_len = %" PRIu64 ", context = ", addr, dst, (uint64_t)dst_len); context.Dump(strm, instruction); - log->PutCString(strm.GetData()); + log->PutString(strm.GetString()); } memset(dst, 0, dst_len); return dst_len; @@ -412,7 +411,7 @@ size_t UnwindAssemblyInstEmulation::WriteMemory( data.Dump(&strm, 0, eFormatBytes, 1, dst_len, UINT32_MAX, addr, 0, 0); strm.PutCString(", context = "); context.Dump(strm, instruction); - log->PutCString(strm.GetData()); + log->PutString(strm.GetString()); } const bool cant_replace = false; @@ -493,7 +492,7 @@ bool UnwindAssemblyInstEmulation::ReadRegister(EmulateInstruction *instruction, "synthetic_value = %i, value = ", reg_info->name, synthetic); reg_value.Dump(&strm, reg_info, false, false, eFormatDefault); - log->PutCString(strm.GetData()); + log->PutString(strm.GetString()); } return true; } @@ -521,7 +520,7 @@ bool UnwindAssemblyInstEmulation::WriteRegister( reg_value.Dump(&strm, reg_info, false, false, eFormatDefault); strm.PutCString(", context = "); context.Dump(strm, instruction); - log->PutCString(strm.GetData()); + log->PutString(strm.GetString()); } SetRegisterValue(*reg_info, reg_value); diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index a89ebfb..0b1d6b2 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -646,5 +646,5 @@ ConstString ObjectFile::GetNextSyntheticSymbolName() { ConstString file_name = GetModule()->GetFileSpec().GetFilename(); ss.Printf("___lldb_unnamed_symbol%u$$%s", ++m_synthetic_symbol_idx, file_name.GetCString()); - return ConstString(ss.GetData()); + return ConstString(ss.GetString()); } diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 86cd6e8..2a61763 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -388,10 +388,10 @@ void ProcessInstanceInfo::DumpAsTableRow(Stream &s, Platform *platform, else s.Printf("%-10u ", m_egid); - s.Printf("%-24s ", arch_strm.GetString().c_str()); + s.Printf("%-24s ", arch_strm.GetData()); } else { s.Printf("%-10s %-24s ", platform->GetUserName(m_euid), - arch_strm.GetString().c_str()); + arch_strm.GetData()); } if (verbose || show_args) { @@ -5540,7 +5540,7 @@ Process::RunThreadPlan(ExecutionContext &exe_ctx, StreamString s; s.PutCString("Thread state after unsuccessful completion: \n"); thread->GetStackFrameStatus(s, 0, UINT32_MAX, true, UINT32_MAX); - log->PutCString(s.GetData()); + log->PutString(s.GetString()); } // Restore the thread state if we are going to discard the plan execution. // There are three cases where this diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 9ef6109..2676056 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -639,16 +639,14 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( error.SetErrorStringWithFormat( "\"%s\" is a pointer and . was used to attempt to access " "\"%s\". Did you mean \"%s->%s\"?", - var_expr_path_strm.GetString().c_str(), - child_name.GetCString(), - var_expr_path_strm.GetString().c_str(), var_path.c_str()); + var_expr_path_strm.GetData(), child_name.GetCString(), + var_expr_path_strm.GetData(), var_path.c_str()); else error.SetErrorStringWithFormat( "\"%s\" is not a pointer and -> was used to attempt to " "access \"%s\". Did you mean \"%s.%s\"?", - var_expr_path_strm.GetString().c_str(), - child_name.GetCString(), - var_expr_path_strm.GetString().c_str(), var_path.c_str()); + var_expr_path_strm.GetData(), child_name.GetCString(), + var_expr_path_strm.GetData(), var_path.c_str()); return ValueObjectSP(); } } @@ -681,11 +679,11 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "\"%s\" is not a member of \"(%s) %s\"", child_name.GetCString(), valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); } else { error.SetErrorStringWithFormat( "incomplete expression path after \"%s\" in \"%s\"", - var_expr_path_strm.GetString().c_str(), var_expr_cstr); + var_expr_path_strm.GetData(), var_expr_cstr); } } return ValueObjectSP(); @@ -726,7 +724,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( error.SetErrorStringWithFormat( "could not dereference \"(%s) %s\"", valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); return ValueObjectSP(); } valobj_sp = temp; @@ -745,7 +743,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( error.SetErrorStringWithFormat( "could not get item 0 for \"(%s) %s\"", valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); return ValueObjectSP(); } valobj_sp = temp; @@ -767,7 +765,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "\"(%s) %s\" is an Objective-C pointer, and cannot be " "subscripted", valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); return ValueObjectSP(); } else if (is_objc_pointer) { @@ -782,7 +780,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( error.SetErrorStringWithFormat( "\"(%s) %s\" is not an array type", valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); } else if ( static_cast(child_index) >= synthetic @@ -792,7 +790,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "array index %ld is not valid for \"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); } else { child_valobj_sp = synthetic->GetChildAtIndex(child_index, true); @@ -802,7 +800,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "array index %ld is not valid for \"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString( ""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); } } } else { @@ -815,7 +813,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "\"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); } } } else if (valobj_sp->GetCompilerType().IsArrayType( @@ -836,7 +834,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "array index %ld is not valid for \"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); } } else if (valobj_sp->GetCompilerType().IsScalarType()) { // this is a bitfield asking to display just one bit @@ -848,7 +846,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "bitfield range %ld-%ld is not valid for \"(%s) %s\"", child_index, child_index, valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); } } else { ValueObjectSP synthetic = valobj_sp->GetSyntheticValue(); @@ -861,7 +859,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( error.SetErrorStringWithFormat( "\"(%s) %s\" is not an array type", valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); } else if ( static_cast(child_index) >= synthetic @@ -871,7 +869,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "array index %ld is not valid for \"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); } else { child_valobj_sp = synthetic->GetChildAtIndex(child_index, true); @@ -881,7 +879,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "array index %ld is not valid for \"(%s) %s\"", child_index, valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); } } } @@ -932,7 +930,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( error.SetErrorStringWithFormat( "could not dereference \"(%s) %s\"", valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); return ValueObjectSP(); } valobj_sp = temp; @@ -954,7 +952,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( error.SetErrorStringWithFormat( "could not get item 0 for \"(%s) %s\"", valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); return ValueObjectSP(); } valobj_sp = temp; @@ -977,7 +975,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( final_index, valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.c_str()); } }*/ @@ -990,7 +988,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( "bitfield range %ld-%ld is not valid for \"(%s) %s\"", child_index, final_index, valobj_sp->GetTypeName().AsCString(""), - var_expr_path_strm.GetString().c_str()); + var_expr_path_strm.GetData()); } } } @@ -1017,7 +1015,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( } else { error.SetErrorStringWithFormat( "invalid square bracket encountered after \"%s\" in \"%s\"", - var_expr_path_strm.GetString().c_str(), var_path.c_str()); + var_expr_path_strm.GetData(), var_path.c_str()); } return ValueObjectSP(); @@ -1027,7 +1025,7 @@ ValueObjectSP StackFrame::GetValueForVariableExpressionPath( valobj_sp->GetExpressionPath(var_expr_path_strm, false); error.SetErrorStringWithFormat( "unexpected char '%c' encountered after \"%s\" in \"%s\"", - separator_type, var_expr_path_strm.GetString().c_str(), + separator_type, var_expr_path_strm.GetData(), var_path.c_str()); return ValueObjectSP(); @@ -1753,7 +1751,7 @@ void StackFrame::DumpUsingSettingsFormat(Stream *strm, frame_format = target->GetDebugger().GetFrameFormat(); if (frame_format && FormatEntity::Format(*frame_format, s, &m_sc, &exe_ctx, nullptr, nullptr, false, false)) { - strm->Write(s.GetData(), s.GetSize()); + strm->PutCString(s.GetString()); } else { Dump(strm, true, false); strm->EOL(); @@ -1790,8 +1788,10 @@ void StackFrame::UpdateCurrentFrameFromPreviousFrame(StackFrame &prev_frame) { prev_frame.GetStackID()); // TODO: remove this after some testing m_variable_list_sp = prev_frame.m_variable_list_sp; m_variable_list_value_objects.Swap(prev_frame.m_variable_list_value_objects); - if (!m_disassembly.GetString().empty()) - m_disassembly.GetString().swap(m_disassembly.GetString()); + if (!m_disassembly.GetString().empty()) { + m_disassembly.Clear(); + m_disassembly.PutCString(prev_frame.m_disassembly.GetString()); + } } void StackFrame::UpdatePreviousFrameFromCurrentFrame(StackFrame &curr_frame) { diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp index 1f221d6..6b589dd 100644 --- a/lldb/source/Target/StopInfo.cpp +++ b/lldb/source/Target/StopInfo.cpp @@ -216,7 +216,7 @@ public: strm.Printf("breakpoint "); bp_site_sp->GetDescription(&strm, eDescriptionLevelBrief); - m_description.swap(strm.GetString()); + m_description = strm.GetString(); } else { StreamString strm; if (m_break_id != LLDB_INVALID_BREAK_ID) { @@ -249,7 +249,7 @@ public: " which has been deleted - was at 0x%" PRIx64, m_value, m_address); - m_description.swap(strm.GetString()); + m_description = strm.GetString(); } } } @@ -610,7 +610,7 @@ public: if (m_description.empty()) { StreamString strm; strm.Printf("watchpoint %" PRIi64, m_value); - m_description.swap(strm.GetString()); + m_description = strm.GetString(); } return m_description.c_str(); } @@ -950,7 +950,7 @@ public: strm.Printf("signal %s", signal_name); else strm.Printf("signal %" PRIi64, m_value); - m_description.swap(strm.GetString()); + m_description = strm.GetString(); } } return m_description.c_str(); @@ -1021,7 +1021,7 @@ public: if (m_description.empty()) { StreamString strm; m_plan_sp->GetDescription(&strm, eDescriptionLevelBrief); - m_description.swap(strm.GetString()); + m_description = strm.GetString(); } return m_description.c_str(); } diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 53909d2..4344d4c 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -3109,7 +3109,7 @@ void Target::StopHook::GetDescription(Stream *s, s->Indent("Thread:\n"); m_thread_spec_ap->GetDescription(&tmp, level); s->SetIndentLevel(indent_level + 4); - s->Indent(tmp.GetData()); + s->Indent(tmp.GetString()); s->PutCString("\n"); s->SetIndentLevel(indent_level + 2); } diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp index 5d9851a..97910ce 100644 --- a/lldb/source/Target/TargetList.cpp +++ b/lldb/source/Target/TargetList.cpp @@ -152,8 +152,7 @@ Error TargetList::CreateTargetInternal( error.SetErrorStringWithFormat( "the specified architecture '%s' is not compatible with '%s' " "in '%s'", - platform_arch_strm.GetString().c_str(), - module_arch_strm.GetString().c_str(), + platform_arch_strm.GetData(), module_arch_strm.GetData(), module_spec.GetFileSpec().GetPath().c_str()); return error; } @@ -254,7 +253,7 @@ Error TargetList::CreateTargetInternal( } error_strm.Printf( "), use the --platform option to specify a platform"); - error.SetErrorString(error_strm.GetString().c_str()); + error.SetErrorString(error_strm.GetString()); return error; } } diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index 8e2a9c7..5ead590 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -1747,8 +1747,7 @@ Error Thread::JumpToLine(const FileSpec &file, uint32_t line, StreamString sstr; DumpAddressList(sstr, outside_function, target); return Error("%s:%i has multiple candidate locations:\n%s", - file.GetFilename().AsCString(), line, - sstr.GetString().c_str()); + file.GetFilename().AsCString(), line, sstr.GetData()); } } diff --git a/lldb/source/Target/ThreadPlanCallFunction.cpp b/lldb/source/Target/ThreadPlanCallFunction.cpp index f9efb27..68fd503 100644 --- a/lldb/source/Target/ThreadPlanCallFunction.cpp +++ b/lldb/source/Target/ThreadPlanCallFunction.cpp @@ -192,7 +192,7 @@ void ThreadPlanCallFunction::ReportRegisterState(const char *message) { strm.EOL(); } } - log->PutCString(strm.GetData()); + log->PutString(strm.GetString()); } } @@ -257,7 +257,7 @@ bool ThreadPlanCallFunction::ValidatePlan(Stream *error) { if (!m_valid) { if (error) { if (m_constructor_errors.GetSize() > 0) - error->PutCString(m_constructor_errors.GetData()); + error->PutCString(m_constructor_errors.GetString()); else error->PutCString("Unknown error"); } diff --git a/lldb/source/Target/ThreadPlanCallUserExpression.cpp b/lldb/source/Target/ThreadPlanCallUserExpression.cpp index dcd5c8c..260118c 100644 --- a/lldb/source/Target/ThreadPlanCallUserExpression.cpp +++ b/lldb/source/Target/ThreadPlanCallUserExpression.cpp @@ -1,5 +1,4 @@ -//===-- ThreadPlanCallUserExpression.cpp ------------------------------*- C++ -//-*-===// +//===-- ThreadPlanCallUserExpression.cpp -------------------------*- C++-*-===// // // The LLVM Compiler Infrastructure // diff --git a/lldb/source/Target/ThreadPlanStepOverRange.cpp b/lldb/source/Target/ThreadPlanStepOverRange.cpp index 2ded595..c8fd6f9 100644 --- a/lldb/source/Target/ThreadPlanStepOverRange.cpp +++ b/lldb/source/Target/ThreadPlanStepOverRange.cpp @@ -422,7 +422,7 @@ bool ThreadPlanStepOverRange::DoWillResume(lldb::StateType resume_state, "Stepping over inlined function \"%s\" in inlined stack: ", name); DumpRanges(&s); - log->PutCString(s.GetData()); + log->PutString(s.GetString()); } } } diff --git a/lldb/tools/argdumper/argdumper.cpp b/lldb/tools/argdumper/argdumper.cpp index 39991b6..01a070e 100644 --- a/lldb/tools/argdumper/argdumper.cpp +++ b/lldb/tools/argdumper/argdumper.cpp @@ -1,5 +1,4 @@ -//===-- argdumper.cpp --------------------------------------------*- C++ -//-*-===// +//===-- argdumper.cpp --------------------------------------------*- C++-*-===// // // The LLVM Compiler Infrastructure // diff --git a/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp b/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp index 590b143..202a65b 100644 --- a/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp +++ b/lldb/unittests/ScriptInterpreter/Python/PythonDataObjectsTests.cpp @@ -255,17 +255,17 @@ TEST_F(PythonDataObjectsTest, TestPythonString) { // Test that creating a `PythonString` object works correctly with the // string constructor PythonString constructed_string(test_string2); - EXPECT_STREQ(test_string2, constructed_string.GetString().str().c_str()); + EXPECT_STREQ(test_string2, constructed_string.c_str()); } TEST_F(PythonDataObjectsTest, TestPythonStringToStr) { const char *c_str = "PythonDataObjectsTest::TestPythonStringToStr"; PythonString str(c_str); - EXPECT_STREQ(c_str, str.GetString().str().c_str()); + EXPECT_STREQ(c_str, str.c_str()); PythonString str_str = str.Str(); - EXPECT_STREQ(c_str, str_str.GetString().str().c_str()); + EXPECT_STREQ(c_str, str_str.c_str()); } TEST_F(PythonDataObjectsTest, TestPythonIntegerToStr) {} @@ -315,7 +315,7 @@ TEST_F(PythonDataObjectsTest, TestPythonListValueEquality) { PythonString chk_str(PyRefType::Borrowed, chk_value2.get()); EXPECT_EQ(long_value0, chk_int.GetInteger()); - EXPECT_STREQ(string_value1, chk_str.GetString().str().c_str()); + EXPECT_STREQ(string_value1, chk_str.c_str()); } TEST_F(PythonDataObjectsTest, TestPythonListManipulation) { @@ -343,7 +343,7 @@ TEST_F(PythonDataObjectsTest, TestPythonListManipulation) { PythonString chk_str(PyRefType::Borrowed, chk_value2.get()); EXPECT_EQ(long_value0, chk_int.GetInteger()); - EXPECT_STREQ(string_value1, chk_str.GetString().str().c_str()); + EXPECT_STREQ(string_value1, chk_str.c_str()); } TEST_F(PythonDataObjectsTest, TestPythonListToStructuredList) { @@ -466,7 +466,7 @@ TEST_F(PythonDataObjectsTest, TestPythonDictionaryValueEquality) { PythonString chk_str(PyRefType::Borrowed, chk_value2.get()); EXPECT_EQ(value_0, chk_int.GetInteger()); - EXPECT_STREQ(value_1, chk_str.GetString().str().c_str()); + EXPECT_STREQ(value_1, chk_str.c_str()); } TEST_F(PythonDataObjectsTest, TestPythonDictionaryManipulation) { @@ -503,7 +503,7 @@ TEST_F(PythonDataObjectsTest, TestPythonDictionaryManipulation) { PythonString chk_str(PyRefType::Borrowed, chk_value2.get()); EXPECT_EQ(value_0, chk_int.GetInteger()); - EXPECT_STREQ(value_1, chk_str.GetString().str().c_str()); + EXPECT_STREQ(value_1, chk_str.c_str()); } TEST_F(PythonDataObjectsTest, TestPythonDictionaryToStructuredDictionary) { -- 2.7.4