summaryrefslogtreecommitdiff
path: root/lldb/source/Core
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2016-11-16 21:15:24 +0000
committerZachary Turner <zturner@google.com>2016-11-16 21:15:24 +0000
commit75e2ff7fb0216e3ff168a9af06aac236fcce02da (patch)
treed7656940546273d77f88117071b98a64bc6ee901 /lldb/source/Core
parent2cc783b03d68a3e78c24f980daec8b9abd2dda62 (diff)
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
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/Address.cpp2
-rw-r--r--lldb/source/Core/DataExtractor.cpp6
-rw-r--r--lldb/source/Core/Debugger.cpp2
-rw-r--r--lldb/source/Core/Disassembler.cpp2
-rw-r--r--lldb/source/Core/EmulateInstruction.cpp4
-rw-r--r--lldb/source/Core/Error.cpp13
-rw-r--r--lldb/source/Core/Event.cpp2
-rw-r--r--lldb/source/Core/FormatEntity.cpp27
-rw-r--r--lldb/source/Core/IOHandler.cpp18
-rw-r--r--lldb/source/Core/Log.cpp1
-rw-r--r--lldb/source/Core/Module.cpp12
-rw-r--r--lldb/source/Core/RegisterValue.cpp10
-rw-r--r--lldb/source/Core/StreamString.cpp6
-rw-r--r--lldb/source/Core/StringList.cpp2
-rw-r--r--lldb/source/Core/StructuredData.cpp5
-rw-r--r--lldb/source/Core/ValueObject.cpp52
16 files changed, 78 insertions, 86 deletions
diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp
index 6933aba2d07..e2ccf9d7221 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 466f111b3b1..fbc6e80bea0 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 1577a38f336..24715ec2129 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 577f2f6d474..c55ad1c1755 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 800ff8e4484..4ad5b4e1d57 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 d91f16d6b7e..23696127d3b 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 85da9b855fa..bd57198f548 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<const void *>(this),
static_cast<void *>(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<const void *>(this),
diff --git a/lldb/source/Core/FormatEntity.cpp b/lldb/source/Core/FormatEntity.cpp
index 85965be35e5..bd2e5361800 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 315d20ed24b..e123fdb1431 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 30b6188d04c..53195006b3b 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 9ce03d6d4de..220773b5ad4 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 509919dad2c..62d83050dff 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 cb088085b1e..461648815f1 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 cde02e19732..226db21609a 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 48c368d91c9..1e190f52314 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 cd6bc8998a2..e349e03f236 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("<invalid type>"),
- strm.GetString().c_str());
+ strm.GetData());
else
error.SetErrorStringWithFormat("not a pointer or reference type: (%s) %s",
GetTypeName().AsCString("<invalid type>"),
- 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;