Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions lldb/source/Core/FormatEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2170,13 +2170,11 @@ static Status ParseInternal(llvm::StringRef &format, Entry &parent_entry,
} break;

case '$':
if (format.size() == 1) {
// '$' at the end of a format string, just print the '$'
format = format.drop_front(); // Skip the '$'
if (format.empty() || format.front() != '{') {
// Print '$' when not followed by '{'.
parent_entry.AppendText("$");
} else {
format = format.drop_front(); // Skip the '$'

if (format[0] == '{') {
format = format.drop_front(); // Skip the '{'

llvm::StringRef variable, variable_format;
Expand Down Expand Up @@ -2229,18 +2227,16 @@ static Status ParseInternal(llvm::StringRef &format, Entry &parent_entry,
clear_printf = true;
break;
case 'T': // if this is a 'T', print the type
entry.number =
ValueObject::eValueObjectRepresentationStyleType;
entry.number = ValueObject::eValueObjectRepresentationStyleType;
clear_printf = true;
break;
case 'N': // if this is a 'N', print the name
entry.number =
ValueObject::eValueObjectRepresentationStyleName;
entry.number = ValueObject::eValueObjectRepresentationStyleName;
clear_printf = true;
break;
case '>': // if this is a '>', print the expression path
entry.number = ValueObject::
eValueObjectRepresentationStyleExpressionPath;
entry.number =
ValueObject::eValueObjectRepresentationStyleExpressionPath;
clear_printf = true;
break;
}
Expand Down Expand Up @@ -2299,8 +2295,7 @@ static Status ParseInternal(llvm::StringRef &format, Entry &parent_entry,
case Entry::Type::VariableSynthetic:
if (entry.number == 0) {
if (entry.string.empty())
entry.number =
ValueObject::eValueObjectRepresentationStyleValue;
entry.number = ValueObject::eValueObjectRepresentationStyleValue;
else
entry.number =
ValueObject::eValueObjectRepresentationStyleSummary;
Expand All @@ -2318,7 +2313,6 @@ static Status ParseInternal(llvm::StringRef &format, Entry &parent_entry,
}
parent_entry.AppendEntry(std::move(entry));
}
}
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C_SOURCES = main.c
include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class TestCase(TestBase):
def test_summary_string_with_bare_dollar_char(self):
self.build()
lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.c"))
self.runCmd("type summary add --summary-string '$ $CASH $' --no-value Dollars")
self.expect("v cash", startstr="(Dollars) cash = $ $CASH $")

def test_summary_string_with_bare_dollar_char_before_var(self):
self.build()
lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.c"))
self.runCmd("type summary add --summary-string '$${var}' --no-value Dollars")
self.expect("v cash", startstr="(Dollars) cash = $99")
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include <stdio.h>

typedef int Dollars;

int main() {
Dollars cash = 99;
printf("break here: %d\n", cash);
return 0;
}