summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/lit/Settings/TestDisassemblyFormat.test2
-rw-r--r--lldb/source/Interpreter/OptionValueFormatEntity.cpp18
2 files changed, 19 insertions, 1 deletions
diff --git a/lldb/lit/Settings/TestDisassemblyFormat.test b/lldb/lit/Settings/TestDisassemblyFormat.test
new file mode 100644
index 00000000000..29975a1b016
--- /dev/null
+++ b/lldb/lit/Settings/TestDisassemblyFormat.test
@@ -0,0 +1,2 @@
+# RUN: %lldb -x -b -o "settings show disassembly-format" | FileCheck %s
+# CHECK: disassembly-format (format-string) = "{${function.initial-function}{${module.file.basename}\`}{${function.name-without-args}}:\n}{${function.changed}\n{${module.file.basename}\`}{${function.name-without-args}}:\n}{${current-pc-arrow} }${addr-file-or-load}{ <${function.concrete-only-addr-offset-no-padding}>}: "
diff --git a/lldb/source/Interpreter/OptionValueFormatEntity.cpp b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
index ce1a84e8dec..3501423a732 100644
--- a/lldb/source/Interpreter/OptionValueFormatEntity.cpp
+++ b/lldb/source/Interpreter/OptionValueFormatEntity.cpp
@@ -41,6 +41,20 @@ bool OptionValueFormatEntity::Clear() {
return true;
}
+static void EscapeBackticks(llvm::StringRef str, std::string &dst) {
+ dst.clear();
+ dst.reserve(str.size());
+
+ for (size_t i = 0, e = str.size(); i != e; ++i) {
+ char c = str[i];
+ if (c == '`') {
+ if (i == 0 || str[i - 1] != '\\')
+ dst += '\\';
+ }
+ dst += c;
+ }
+}
+
void OptionValueFormatEntity::DumpValue(const ExecutionContext *exe_ctx,
Stream &strm, uint32_t dump_mask) {
if (dump_mask & eDumpOptionType)
@@ -48,7 +62,9 @@ void OptionValueFormatEntity::DumpValue(const ExecutionContext *exe_ctx,
if (dump_mask & eDumpOptionValue) {
if (dump_mask & eDumpOptionType)
strm.PutCString(" = \"");
- strm << m_current_format.c_str() << '"';
+ std::string escaped;
+ EscapeBackticks(m_current_format, escaped);
+ strm << escaped << '"';
}
}
OpenPOWER on IntegriCloud