[lldb][NFC] Fix all formatting errors in .cpp file headers
Summary:
A *.cpp file header in LLDB (and in LLDB) should like this:
```
//===-- TestUtilities.cpp -------------------------------------------------===//
```
However in LLDB most of our source files have arbitrary changes to this format and
these changes are spreading through LLDB as folks usually just use the existing
source files as templates for their new files (most notably the unnecessary
editor language indicator `-*- C++ -*-` is spreading and in every review
someone is pointing out that this is wrong, resulting in people pointing out that this
is done in the same way in other files).
This patch removes most of these inconsistencies including the editor language indicators,
all the different missing/additional '-' characters, files that center the file name, missing
trailing `===//` (mostly caused by clang-format breaking the line).
Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D73258
2020-01-24 15:23:27 +08:00
|
|
|
//===-- DWARFExpressionTest.cpp -------------------------------------------===//
|
2019-04-29 18:55:22 +08:00
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Expression/DWARFExpression.h"
|
2021-02-12 07:04:10 +08:00
|
|
|
#include "Plugins/Platform/Linux/PlatformLinux.h"
|
2020-02-05 06:05:15 +08:00
|
|
|
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
|
2020-02-05 05:59:29 +08:00
|
|
|
#include "TestingSupport/Symbol/YAMLModuleTester.h"
|
2019-04-29 18:55:22 +08:00
|
|
|
#include "lldb/Core/Value.h"
|
2021-02-12 07:04:10 +08:00
|
|
|
#include "lldb/Core/Debugger.h"
|
2019-04-29 18:55:22 +08:00
|
|
|
#include "lldb/Core/dwarf.h"
|
2021-02-12 07:04:10 +08:00
|
|
|
#include "lldb/Host/HostInfo.h"
|
2019-09-11 00:17:38 +08:00
|
|
|
#include "lldb/Symbol/ObjectFile.h"
|
2021-02-12 07:04:10 +08:00
|
|
|
#include "lldb/Utility/Reproducer.h"
|
2019-04-29 18:55:22 +08:00
|
|
|
#include "lldb/Utility/StreamString.h"
|
|
|
|
#include "llvm/ADT/StringExtras.h"
|
|
|
|
#include "llvm/Testing/Support/Error.h"
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
2019-10-22 06:46:53 +08:00
|
|
|
static llvm::Expected<Scalar> Evaluate(llvm::ArrayRef<uint8_t> expr,
|
|
|
|
lldb::ModuleSP module_sp = {},
|
2021-02-12 07:04:10 +08:00
|
|
|
DWARFUnit *unit = nullptr,
|
|
|
|
ExecutionContext *exe_ctx = nullptr) {
|
2019-10-22 06:46:53 +08:00
|
|
|
DataExtractor extractor(expr.data(), expr.size(), lldb::eByteOrderLittle,
|
|
|
|
/*addr_size*/ 4);
|
|
|
|
Value result;
|
|
|
|
Status status;
|
2021-02-12 07:04:10 +08:00
|
|
|
if (!DWARFExpression::Evaluate(exe_ctx, /*reg_ctx*/ nullptr, module_sp,
|
|
|
|
extractor, unit, lldb::eRegisterKindLLDB,
|
|
|
|
/*initial_value_ptr*/ nullptr,
|
|
|
|
/*object_address_ptr*/ nullptr, result,
|
|
|
|
&status))
|
2019-10-22 06:46:53 +08:00
|
|
|
return status.ToError();
|
|
|
|
|
2020-01-17 06:21:03 +08:00
|
|
|
switch (result.GetValueType()) {
|
2021-02-12 04:57:04 +08:00
|
|
|
case Value::ValueType::Scalar:
|
2020-01-17 06:21:03 +08:00
|
|
|
return result.GetScalar();
|
2021-03-03 03:03:38 +08:00
|
|
|
case Value::ValueType::LoadAddress:
|
|
|
|
return LLDB_INVALID_ADDRESS;
|
2021-02-12 04:57:04 +08:00
|
|
|
case Value::ValueType::HostAddress: {
|
2020-01-17 06:21:03 +08:00
|
|
|
// Convert small buffers to scalars to simplify the tests.
|
|
|
|
DataBufferHeap &buf = result.GetBuffer();
|
|
|
|
if (buf.GetByteSize() <= 8) {
|
|
|
|
uint64_t val = 0;
|
|
|
|
memcpy(&val, buf.GetBytes(), buf.GetByteSize());
|
|
|
|
return Scalar(llvm::APInt(buf.GetByteSize()*8, val, false));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LLVM_FALLTHROUGH;
|
|
|
|
default:
|
|
|
|
return status.ToError();
|
|
|
|
}
|
2019-10-22 06:46:53 +08:00
|
|
|
}
|
|
|
|
|
2020-02-05 05:59:29 +08:00
|
|
|
class DWARFExpressionTester : public YAMLModuleTester {
|
2019-09-11 00:17:38 +08:00
|
|
|
public:
|
2020-02-05 05:59:29 +08:00
|
|
|
using YAMLModuleTester::YAMLModuleTester;
|
2019-10-22 06:46:53 +08:00
|
|
|
llvm::Expected<Scalar> Eval(llvm::ArrayRef<uint8_t> expr) {
|
2020-10-29 21:25:24 +08:00
|
|
|
return ::Evaluate(expr, m_module_sp, m_dwarf_unit);
|
2019-10-22 06:46:53 +08:00
|
|
|
}
|
|
|
|
};
|
2019-04-29 18:55:22 +08:00
|
|
|
|
2019-09-11 00:17:38 +08:00
|
|
|
/// Unfortunately Scalar's operator==() is really picky.
|
|
|
|
static Scalar GetScalar(unsigned bits, uint64_t value, bool sign) {
|
2020-06-24 21:26:42 +08:00
|
|
|
Scalar scalar(value);
|
|
|
|
scalar.TruncOrExtendTo(bits, sign);
|
2019-09-11 00:17:38 +08:00
|
|
|
return scalar;
|
|
|
|
}
|
|
|
|
|
2021-02-12 07:04:10 +08:00
|
|
|
/// This is needed for the tests that use a mock process.
|
|
|
|
class DWARFExpressionMockProcessTest : public ::testing::Test {
|
|
|
|
public:
|
|
|
|
void SetUp() override {
|
|
|
|
llvm::cantFail(repro::Reproducer::Initialize(repro::ReproducerMode::Off, {}));
|
|
|
|
FileSystem::Initialize();
|
|
|
|
HostInfo::Initialize();
|
|
|
|
platform_linux::PlatformLinux::Initialize();
|
|
|
|
}
|
|
|
|
void TearDown() override {
|
|
|
|
platform_linux::PlatformLinux::Terminate();
|
|
|
|
HostInfo::Terminate();
|
|
|
|
FileSystem::Terminate();
|
|
|
|
repro::Reproducer::Terminate();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-04-29 18:55:22 +08:00
|
|
|
TEST(DWARFExpression, DW_OP_pick) {
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit1, DW_OP_lit0, DW_OP_pick, 0}),
|
|
|
|
llvm::HasValue(0));
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit1, DW_OP_lit0, DW_OP_pick, 1}),
|
|
|
|
llvm::HasValue(1));
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit1, DW_OP_lit0, DW_OP_pick, 2}),
|
|
|
|
llvm::Failed());
|
|
|
|
}
|
2019-09-11 00:17:38 +08:00
|
|
|
|
2020-11-05 17:28:31 +08:00
|
|
|
TEST(DWARFExpression, DW_OP_const) {
|
|
|
|
// Extend to address size.
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const1u, 0x88}), llvm::HasValue(0x88));
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const1s, 0x88}),
|
|
|
|
llvm::HasValue(0xffffff88));
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x47, 0x88}),
|
|
|
|
llvm::HasValue(0x8847));
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2s, 0x47, 0x88}),
|
|
|
|
llvm::HasValue(0xffff8847));
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const4u, 0x44, 0x42, 0x47, 0x88}),
|
|
|
|
llvm::HasValue(0x88474244));
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const4s, 0x44, 0x42, 0x47, 0x88}),
|
|
|
|
llvm::HasValue(0x88474244));
|
|
|
|
|
|
|
|
// Truncate to address size.
|
|
|
|
EXPECT_THAT_EXPECTED(
|
|
|
|
Evaluate({DW_OP_const8u, 0x00, 0x11, 0x22, 0x33, 0x44, 0x42, 0x47, 0x88}),
|
|
|
|
llvm::HasValue(0x33221100));
|
|
|
|
EXPECT_THAT_EXPECTED(
|
|
|
|
Evaluate({DW_OP_const8s, 0x00, 0x11, 0x22, 0x33, 0x44, 0x42, 0x47, 0x88}),
|
|
|
|
llvm::HasValue(0x33221100));
|
|
|
|
|
|
|
|
// Don't truncate to address size for compatibility with clang (pr48087).
|
|
|
|
EXPECT_THAT_EXPECTED(
|
|
|
|
Evaluate({DW_OP_constu, 0x81, 0x82, 0x84, 0x88, 0x90, 0xa0, 0x40}),
|
|
|
|
llvm::HasValue(0x01010101010101));
|
|
|
|
EXPECT_THAT_EXPECTED(
|
|
|
|
Evaluate({DW_OP_consts, 0x81, 0x82, 0x84, 0x88, 0x90, 0xa0, 0x40}),
|
|
|
|
llvm::HasValue(0xffff010101010101));
|
|
|
|
}
|
|
|
|
|
2019-09-11 00:17:38 +08:00
|
|
|
TEST(DWARFExpression, DW_OP_convert) {
|
|
|
|
/// Auxiliary debug info.
|
2020-10-29 21:25:24 +08:00
|
|
|
const char *yamldata = R"(
|
|
|
|
--- !ELF
|
|
|
|
FileHeader:
|
|
|
|
Class: ELFCLASS64
|
|
|
|
Data: ELFDATA2LSB
|
|
|
|
Type: ET_EXEC
|
|
|
|
Machine: EM_386
|
|
|
|
DWARF:
|
|
|
|
debug_abbrev:
|
|
|
|
- Table:
|
|
|
|
- Code: 0x00000001
|
|
|
|
Tag: DW_TAG_compile_unit
|
|
|
|
Children: DW_CHILDREN_yes
|
|
|
|
Attributes:
|
|
|
|
- Attribute: DW_AT_language
|
|
|
|
Form: DW_FORM_data2
|
|
|
|
- Code: 0x00000002
|
|
|
|
Tag: DW_TAG_base_type
|
|
|
|
Children: DW_CHILDREN_no
|
|
|
|
Attributes:
|
|
|
|
- Attribute: DW_AT_encoding
|
|
|
|
Form: DW_FORM_data1
|
|
|
|
- Attribute: DW_AT_byte_size
|
|
|
|
Form: DW_FORM_data1
|
|
|
|
debug_info:
|
|
|
|
- Version: 4
|
|
|
|
AddrSize: 8
|
|
|
|
Entries:
|
|
|
|
- AbbrCode: 0x00000001
|
|
|
|
Values:
|
|
|
|
- Value: 0x000000000000000C
|
|
|
|
# 0x0000000e:
|
|
|
|
- AbbrCode: 0x00000002
|
|
|
|
Values:
|
|
|
|
- Value: 0x0000000000000007 # DW_ATE_unsigned
|
|
|
|
- Value: 0x0000000000000004
|
|
|
|
# 0x00000011:
|
|
|
|
- AbbrCode: 0x00000002
|
|
|
|
Values:
|
|
|
|
- Value: 0x0000000000000007 # DW_ATE_unsigned
|
|
|
|
- Value: 0x0000000000000008
|
|
|
|
# 0x00000014:
|
|
|
|
- AbbrCode: 0x00000002
|
|
|
|
Values:
|
|
|
|
- Value: 0x0000000000000005 # DW_ATE_signed
|
|
|
|
- Value: 0x0000000000000008
|
|
|
|
# 0x00000017:
|
|
|
|
- AbbrCode: 0x00000002
|
|
|
|
Values:
|
|
|
|
- Value: 0x0000000000000008 # DW_ATE_unsigned_char
|
|
|
|
- Value: 0x0000000000000001
|
|
|
|
# 0x0000001a:
|
|
|
|
- AbbrCode: 0x00000002
|
|
|
|
Values:
|
|
|
|
- Value: 0x0000000000000006 # DW_ATE_signed_char
|
|
|
|
- Value: 0x0000000000000001
|
|
|
|
# 0x0000001d:
|
|
|
|
- AbbrCode: 0x00000002
|
|
|
|
Values:
|
|
|
|
- Value: 0x000000000000000b # DW_ATE_numeric_string
|
|
|
|
- Value: 0x0000000000000001
|
|
|
|
- AbbrCode: 0x00000000
|
|
|
|
)";
|
2019-09-11 00:17:38 +08:00
|
|
|
uint8_t offs_uint32_t = 0x0000000e;
|
|
|
|
uint8_t offs_uint64_t = 0x00000011;
|
|
|
|
uint8_t offs_sint64_t = 0x00000014;
|
|
|
|
uint8_t offs_uchar = 0x00000017;
|
|
|
|
uint8_t offs_schar = 0x0000001a;
|
|
|
|
|
2020-10-29 21:25:24 +08:00
|
|
|
DWARFExpressionTester t(yamldata);
|
2019-10-22 06:46:53 +08:00
|
|
|
ASSERT_TRUE((bool)t.GetDwarfUnit());
|
2019-09-11 00:17:38 +08:00
|
|
|
|
|
|
|
// Constant is given as little-endian.
|
|
|
|
bool is_signed = true;
|
|
|
|
bool not_signed = false;
|
|
|
|
|
2019-10-22 06:46:53 +08:00
|
|
|
//
|
|
|
|
// Positive tests.
|
|
|
|
//
|
2019-10-22 06:48:27 +08:00
|
|
|
|
2020-11-05 17:28:31 +08:00
|
|
|
// Leave as is.
|
2021-03-23 09:09:46 +08:00
|
|
|
EXPECT_THAT_EXPECTED(
|
|
|
|
t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
|
|
|
|
DW_OP_convert, offs_uint32_t, DW_OP_stack_value}),
|
|
|
|
llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
|
2019-09-11 00:17:38 +08:00
|
|
|
|
2020-11-05 17:28:31 +08:00
|
|
|
// Zero-extend to 64 bits.
|
2021-03-23 09:09:46 +08:00
|
|
|
EXPECT_THAT_EXPECTED(
|
|
|
|
t.Eval({DW_OP_const4u, 0x11, 0x22, 0x33, 0x44, //
|
|
|
|
DW_OP_convert, offs_uint64_t, DW_OP_stack_value}),
|
|
|
|
llvm::HasValue(GetScalar(64, 0x44332211, not_signed)));
|
2019-09-11 00:17:38 +08:00
|
|
|
|
|
|
|
// Sign-extend to 64 bits.
|
|
|
|
EXPECT_THAT_EXPECTED(
|
2019-10-22 06:46:53 +08:00
|
|
|
t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
|
2021-03-23 09:09:46 +08:00
|
|
|
DW_OP_convert, offs_sint64_t, DW_OP_stack_value}),
|
2019-09-11 00:17:38 +08:00
|
|
|
llvm::HasValue(GetScalar(64, 0xffffffffffeeddcc, is_signed)));
|
|
|
|
|
2020-11-05 17:28:31 +08:00
|
|
|
// Sign-extend, then truncate.
|
2021-03-23 09:09:46 +08:00
|
|
|
EXPECT_THAT_EXPECTED(
|
|
|
|
t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
|
|
|
|
DW_OP_convert, offs_sint64_t, //
|
|
|
|
DW_OP_convert, offs_uint32_t, DW_OP_stack_value}),
|
|
|
|
llvm::HasValue(GetScalar(32, 0xffeeddcc, not_signed)));
|
2020-11-05 17:28:31 +08:00
|
|
|
|
|
|
|
// Truncate to default unspecified (pointer-sized) type.
|
|
|
|
EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 0xcc, 0xdd, 0xee, 0xff, //
|
|
|
|
DW_OP_convert, offs_sint64_t, //
|
2021-03-23 09:09:46 +08:00
|
|
|
DW_OP_convert, 0x00, DW_OP_stack_value}),
|
2020-11-05 17:28:31 +08:00
|
|
|
llvm::HasValue(GetScalar(32, 0xffeeddcc, not_signed)));
|
|
|
|
|
2019-09-11 00:17:38 +08:00
|
|
|
// Truncate to 8 bits.
|
2021-03-23 09:09:46 +08:00
|
|
|
EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert,
|
|
|
|
offs_uchar, DW_OP_stack_value}),
|
|
|
|
llvm::HasValue(GetScalar(8, 'A', not_signed)));
|
2019-09-11 00:17:38 +08:00
|
|
|
|
|
|
|
// Also truncate to 8 bits.
|
2021-03-23 09:09:46 +08:00
|
|
|
EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert,
|
|
|
|
offs_schar, DW_OP_stack_value}),
|
|
|
|
llvm::HasValue(GetScalar(8, 'A', is_signed)));
|
2019-09-11 00:17:38 +08:00
|
|
|
|
|
|
|
//
|
|
|
|
// Errors.
|
|
|
|
//
|
|
|
|
|
|
|
|
// No Module.
|
|
|
|
EXPECT_THAT_ERROR(Evaluate({DW_OP_const1s, 'X', DW_OP_convert, 0x00}, nullptr,
|
2020-10-29 21:25:24 +08:00
|
|
|
t.GetDwarfUnit())
|
2019-09-11 00:17:38 +08:00
|
|
|
.takeError(),
|
|
|
|
llvm::Failed());
|
|
|
|
|
|
|
|
// No DIE.
|
2019-10-22 06:46:53 +08:00
|
|
|
EXPECT_THAT_ERROR(
|
|
|
|
t.Eval({DW_OP_const1s, 'X', DW_OP_convert, 0x01}).takeError(),
|
|
|
|
llvm::Failed());
|
2019-09-11 00:17:38 +08:00
|
|
|
|
|
|
|
// Unsupported.
|
2019-10-22 06:46:53 +08:00
|
|
|
EXPECT_THAT_ERROR(
|
|
|
|
t.Eval({DW_OP_const1s, 'X', DW_OP_convert, 0x1d}).takeError(),
|
|
|
|
llvm::Failed());
|
2019-09-11 00:17:38 +08:00
|
|
|
}
|
2020-01-17 06:21:03 +08:00
|
|
|
|
2020-03-31 08:33:42 +08:00
|
|
|
TEST(DWARFExpression, DW_OP_stack_value) {
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_stack_value}), llvm::Failed());
|
|
|
|
}
|
|
|
|
|
2020-01-17 06:21:03 +08:00
|
|
|
TEST(DWARFExpression, DW_OP_piece) {
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_const2u, 0x11, 0x22, DW_OP_piece, 2,
|
|
|
|
DW_OP_const2u, 0x33, 0x44, DW_OP_piece, 2}),
|
|
|
|
llvm::HasValue(GetScalar(32, 0x44332211, true)));
|
2020-01-17 06:21:17 +08:00
|
|
|
EXPECT_THAT_EXPECTED(
|
|
|
|
Evaluate({DW_OP_piece, 1, DW_OP_const1u, 0xff, DW_OP_piece, 1}),
|
|
|
|
// Note that the "00" should really be "undef", but we can't
|
|
|
|
// represent that yet.
|
|
|
|
llvm::HasValue(GetScalar(16, 0xff00, true)));
|
2020-01-17 06:21:03 +08:00
|
|
|
}
|
2020-06-08 21:19:31 +08:00
|
|
|
|
2020-10-21 09:54:48 +08:00
|
|
|
TEST(DWARFExpression, DW_OP_implicit_value) {
|
|
|
|
unsigned char bytes = 4;
|
|
|
|
|
|
|
|
EXPECT_THAT_EXPECTED(
|
|
|
|
Evaluate({DW_OP_implicit_value, bytes, 0x11, 0x22, 0x33, 0x44}),
|
|
|
|
llvm::HasValue(GetScalar(8 * bytes, 0x44332211, true)));
|
|
|
|
}
|
|
|
|
|
2020-06-08 21:19:31 +08:00
|
|
|
TEST(DWARFExpression, DW_OP_unknown) {
|
|
|
|
EXPECT_THAT_EXPECTED(
|
|
|
|
Evaluate({0xff}),
|
|
|
|
llvm::FailedWithMessage(
|
|
|
|
"Unhandled opcode DW_OP_unknown_ff in DWARFExpression"));
|
|
|
|
}
|
2021-02-11 07:50:52 +08:00
|
|
|
|
2021-02-12 07:04:10 +08:00
|
|
|
TEST_F(DWARFExpressionMockProcessTest, DW_OP_deref) {
|
2021-02-11 07:50:52 +08:00
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit0, DW_OP_deref}), llvm::Failed());
|
2021-02-12 07:04:10 +08:00
|
|
|
|
|
|
|
struct MockProcess : Process {
|
|
|
|
using Process::Process;
|
|
|
|
ConstString GetPluginName() override { return ConstString("mock process"); }
|
|
|
|
bool CanDebug(lldb::TargetSP target,
|
|
|
|
bool plugin_specified_by_name) override {
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
Status DoDestroy() override { return {}; }
|
|
|
|
void RefreshStateAfterStop() override {}
|
|
|
|
bool DoUpdateThreadList(ThreadList &old_thread_list,
|
|
|
|
ThreadList &new_thread_list) override {
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
size_t DoReadMemory(lldb::addr_t vm_addr, void *buf, size_t size,
|
|
|
|
Status &error) override {
|
|
|
|
for (size_t i = 0; i < size; ++i)
|
|
|
|
((char *)buf)[i] = (vm_addr + i) & 0xff;
|
|
|
|
error.Clear();
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Set up a mock process.
|
|
|
|
ArchSpec arch("i386-pc-linux");
|
|
|
|
Platform::SetHostPlatform(
|
|
|
|
platform_linux::PlatformLinux::CreateInstance(true, &arch));
|
|
|
|
lldb::DebuggerSP debugger_sp = Debugger::CreateInstance();
|
|
|
|
ASSERT_TRUE(debugger_sp);
|
|
|
|
lldb::TargetSP target_sp;
|
|
|
|
lldb::PlatformSP platform_sp;
|
|
|
|
debugger_sp->GetTargetList().CreateTarget(
|
|
|
|
*debugger_sp, "", arch, eLoadDependentsNo, platform_sp, target_sp);
|
|
|
|
ASSERT_TRUE(target_sp);
|
|
|
|
ASSERT_TRUE(target_sp->GetArchitecture().IsValid());
|
|
|
|
ASSERT_TRUE(platform_sp);
|
|
|
|
lldb::ListenerSP listener_sp(Listener::MakeListener("dummy"));
|
|
|
|
lldb::ProcessSP process_sp =
|
|
|
|
std::make_shared<MockProcess>(target_sp, listener_sp);
|
|
|
|
ASSERT_TRUE(process_sp);
|
|
|
|
|
|
|
|
ExecutionContext exe_ctx(process_sp);
|
2021-03-03 03:03:38 +08:00
|
|
|
// Implicit location: *0x4.
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit4, DW_OP_deref, DW_OP_stack_value},
|
|
|
|
{}, {}, &exe_ctx),
|
2021-02-12 07:04:10 +08:00
|
|
|
llvm::HasValue(GetScalar(32, 0x07060504, false)));
|
2021-03-03 03:03:38 +08:00
|
|
|
// Memory location: *(*0x4).
|
|
|
|
// Evaluate returns LLDB_INVALID_ADDRESS for all load addresses.
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit4, DW_OP_deref}, {}, {}, &exe_ctx),
|
|
|
|
llvm::HasValue(Scalar(LLDB_INVALID_ADDRESS)));
|
2021-03-23 09:09:46 +08:00
|
|
|
// Memory location: *0x4.
|
|
|
|
// Evaluate returns LLDB_INVALID_ADDRESS for all load addresses.
|
|
|
|
EXPECT_THAT_EXPECTED(Evaluate({DW_OP_lit4}, {}, {}, &exe_ctx),
|
|
|
|
llvm::HasValue(Scalar(4)));
|
|
|
|
// Implicit location: *0x4.
|
|
|
|
// Evaluate returns LLDB_INVALID_ADDRESS for all load addresses.
|
|
|
|
EXPECT_THAT_EXPECTED(
|
|
|
|
Evaluate({DW_OP_lit4, DW_OP_deref, DW_OP_stack_value}, {}, {}, &exe_ctx),
|
|
|
|
llvm::HasValue(GetScalar(32, 0x07060504, false)));
|
2021-02-11 07:50:52 +08:00
|
|
|
}
|