[Lldb-commits] [lldb] r360166 - PostfixExpression: Use signed integers in IntegerNode
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Tue May 7 08:58:20 PDT 2019
Author: labath
Date: Tue May 7 08:58:20 2019
New Revision: 360166
URL: http://llvm.org/viewvc/llvm-project?rev=360166&view=rev
Log:
PostfixExpression: Use signed integers in IntegerNode
Summary:
This is necessary to support parsing expressions like ".cfa -16 + ^", as
that format is used in breakpad STACK CFI expressions.
Since the PDB expressions use the same parser, this change will affect
them too, but I don't believe that should be a problem in practice. If
PDBs do contain the negative values, it's very likely that they are
intended to be parsed the same way, and if they don't, then it doesn't
matter.
In case that we do ever need to handle this differently, we can always
make the parser behavior customizable, or just use a different parser.
To make sure that the integer size is big enough for everyone, I switch
from using a (unsigned) 32-bit integer to a 64-bit (signed) one.
Reviewers: amccarth, clayborg, aleksandr.urakov
Subscribers: markmentovai, lldb-commits
Differential Revision: https://reviews.llvm.org/D61311
Modified:
lldb/trunk/include/lldb/Symbol/PostfixExpression.h
lldb/trunk/source/Symbol/PostfixExpression.cpp
lldb/trunk/unittests/Symbol/PostfixExpressionTest.cpp
lldb/trunk/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp
Modified: lldb/trunk/include/lldb/Symbol/PostfixExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/PostfixExpression.h?rev=360166&r1=360165&r2=360166&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/PostfixExpression.h (original)
+++ lldb/trunk/include/lldb/Symbol/PostfixExpression.h Tue May 7 08:58:20 2019
@@ -87,14 +87,14 @@ public:
/// A node representing an integer literal.
class IntegerNode : public Node {
public:
- IntegerNode(uint32_t value) : Node(Integer), m_value(value) {}
+ IntegerNode(int64_t value) : Node(Integer), m_value(value) {}
- uint32_t GetValue() const { return m_value; }
+ int64_t GetValue() const { return m_value; }
static bool classof(const Node *node) { return node->GetKind() == Integer; }
private:
- uint32_t m_value;
+ int64_t m_value;
};
/// A node representing the value of a register with the given register number.
Modified: lldb/trunk/source/Symbol/PostfixExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/PostfixExpression.cpp?rev=360166&r1=360165&r2=360166&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/PostfixExpression.cpp (original)
+++ lldb/trunk/source/Symbol/PostfixExpression.cpp Tue May 7 08:58:20 2019
@@ -67,7 +67,7 @@ Node *postfix::Parse(llvm::StringRef exp
continue;
}
- uint32_t value;
+ int64_t value;
if (to_integer(token, value, 10)) {
// token is integer literal
stack.push_back(MakeNode<IntegerNode>(alloc, value));
@@ -129,8 +129,8 @@ private:
void Visit(InitialValueNode &val, Node *&) override;
void Visit(IntegerNode &integer, Node *&) override {
- m_out_stream.PutHex8(DW_OP_constu);
- m_out_stream.PutULEB128(integer.GetValue());
+ m_out_stream.PutHex8(DW_OP_consts);
+ m_out_stream.PutSLEB128(integer.GetValue());
++m_stack_depth;
}
Modified: lldb/trunk/unittests/Symbol/PostfixExpressionTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Symbol/PostfixExpressionTest.cpp?rev=360166&r1=360165&r2=360166&view=diff
==============================================================================
--- lldb/trunk/unittests/Symbol/PostfixExpressionTest.cpp (original)
+++ lldb/trunk/unittests/Symbol/PostfixExpressionTest.cpp Tue May 7 08:58:20 2019
@@ -88,6 +88,7 @@ TEST(PostfixExpression, Parse) {
EXPECT_EQ("^(^(int(1)))", ParseAndStringify("1 ^ ^"));
EXPECT_EQ("^(+(int(1), ^(int(2))))", ParseAndStringify("1 2 ^ + ^"));
EXPECT_EQ("-($foo, int(47))", ParseAndStringify("$foo 47 -"));
+ EXPECT_EQ("+(int(47), int(-42))", ParseAndStringify("47 -42 +"));
EXPECT_EQ("nullptr", ParseAndStringify("+"));
EXPECT_EQ("nullptr", ParseAndStringify("^"));
@@ -137,7 +138,7 @@ static std::string ParseAndGenerateDWARF
}
TEST(PostfixExpression, ToDWARF) {
- EXPECT_EQ("DW_OP_constu 0x0", ParseAndGenerateDWARF("0"));
+ EXPECT_EQ("DW_OP_consts +0", ParseAndGenerateDWARF("0"));
EXPECT_EQ("DW_OP_breg1 +0", ParseAndGenerateDWARF("R1"));
@@ -151,18 +152,18 @@ TEST(PostfixExpression, ToDWARF) {
EXPECT_EQ("DW_OP_breg1 +0, DW_OP_pick 0x01, DW_OP_plus ",
ParseAndGenerateDWARF("R1 INIT +"));
- EXPECT_EQ("DW_OP_constu 0x1, DW_OP_pick 0x01, DW_OP_deref , DW_OP_plus ",
+ EXPECT_EQ("DW_OP_consts +1, DW_OP_pick 0x01, DW_OP_deref , DW_OP_plus ",
ParseAndGenerateDWARF("1 INIT ^ +"));
- EXPECT_EQ("DW_OP_constu 0x4, DW_OP_constu 0x5, DW_OP_plus ",
+ EXPECT_EQ("DW_OP_consts +4, DW_OP_consts +5, DW_OP_plus ",
ParseAndGenerateDWARF("4 5 +"));
- EXPECT_EQ("DW_OP_constu 0x4, DW_OP_constu 0x5, DW_OP_minus ",
+ EXPECT_EQ("DW_OP_consts +4, DW_OP_consts +5, DW_OP_minus ",
ParseAndGenerateDWARF("4 5 -"));
- EXPECT_EQ("DW_OP_constu 0x4, DW_OP_deref ", ParseAndGenerateDWARF("4 ^"));
+ EXPECT_EQ("DW_OP_consts +4, DW_OP_deref ", ParseAndGenerateDWARF("4 ^"));
- EXPECT_EQ("DW_OP_breg6 +0, DW_OP_constu 0x80, DW_OP_lit1 "
+ EXPECT_EQ("DW_OP_breg6 +0, DW_OP_consts +128, DW_OP_lit1 "
", DW_OP_minus , DW_OP_not , DW_OP_and ",
ParseAndGenerateDWARF("R6 128 @"));
}
Modified: lldb/trunk/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp?rev=360166&r1=360165&r2=360166&view=diff
==============================================================================
--- lldb/trunk/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp (original)
+++ lldb/trunk/unittests/SymbolFile/NativePDB/PdbFPOProgramToDWARFExpressionTests.cpp Tue May 7 08:58:20 2019
@@ -58,20 +58,20 @@ TEST(PDBFPOProgramToDWARFExpressionTests
}
TEST(PDBFPOProgramToDWARFExpressionTests, MultipleIndependentAssignments) {
- CheckValidProgramTranslation("$T1 1 = $T0 0 =", "$T0", "DW_OP_constu 0x0");
+ CheckValidProgramTranslation("$T1 1 = $T0 0 =", "$T0", "DW_OP_consts +0");
}
TEST(PDBFPOProgramToDWARFExpressionTests, MultipleDependentAssignments) {
CheckValidProgramTranslation(
"$T1 $ebp 4 + = $T0 $T1 8 - 128 @ = ", "$T0",
- "DW_OP_breg6 +0, DW_OP_constu 0x4, DW_OP_plus , DW_OP_constu 0x8, "
- "DW_OP_minus , DW_OP_constu 0x80, DW_OP_lit1 , DW_OP_minus , DW_OP_not , "
+ "DW_OP_breg6 +0, DW_OP_consts +4, DW_OP_plus , DW_OP_consts +8, "
+ "DW_OP_minus , DW_OP_consts +128, DW_OP_lit1 , DW_OP_minus , DW_OP_not , "
"DW_OP_and ");
}
TEST(PDBFPOProgramToDWARFExpressionTests, DependencyChain) {
CheckValidProgramTranslation("$T1 0 = $T0 $T1 = $ebp $T0 =", "$ebp",
- "DW_OP_constu 0x0");
+ "DW_OP_consts +0");
}
/// Invalid programs tests
More information about the lldb-commits
mailing list