Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from llvm:master #45

Merged
merged 6 commits into from
Aug 29, 2019
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
6 changes: 3 additions & 3 deletions clang-tools-extra/clangd/clients/clangd-vscode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Protocol](https://github.com/Microsoft/language-server-protocol), such as
code completion, code formatting and goto definition.

**Note**: `clangd` is under heavy development, not all LSP features are
implemented. See [Current Status](https://clang.llvm.org/extra/clangd.html#current-status)
implemented. See [Current Status](https://clang.llvm.org/extra/clangd/Features.html#complete-list-of-features)
for details.

To use `vscode-clangd` extension in VS Code, you need to install `vscode-clangd`
Expand All @@ -25,7 +25,7 @@ Alternatively, the `clangd` executable can be specified in your VS Code
}
```

To obtain `clangd` binary, please see the [installing Clangd](https://clang.llvm.org/extra/clangd.html#installing-clangd).
To obtain `clangd` binary, please see the [installing Clangd](https://clang.llvm.org/extra/clangd/Installation.html#installing-clangd).

## Development

Expand Down Expand Up @@ -68,7 +68,7 @@ to the marketplace.

The extension is published under `llvm-vs-code-extensions` account, which is
currently maintained by clangd developers. If you want to make a new release,
please contact cfe-dev@lists.llvm.org.
please contact clangd-dev@lists.llvm.org.

### Steps

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ CapturedZoneInfo captureZoneInfo(const ExtractionZone &ExtZone) {
// Adds parameters to ExtractedFunc.
// Returns true if able to find the parameters successfully and no hoisting
// needed.
// FIXME: Check if the declaration has a local/anonymous type
bool createParameters(NewFunction &ExtractedFunc,
const CapturedZoneInfo &CapturedInfo) {
for (const auto &KeyVal : CapturedInfo.DeclInfoMap) {
Expand Down
4 changes: 0 additions & 4 deletions lldb/include/lldb/Expression/DWARFExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,6 @@ class DWARFExpression {
lldb::addr_t loclist_base_load_addr,
lldb::addr_t address, ABI *abi);

static size_t LocationListSize(const DWARFUnit *dwarf_cu,
const DataExtractor &debug_loc_data,
lldb::offset_t offset);

static bool PrintDWARFExpression(Stream &s, const DataExtractor &data,
int address_size, int dwarf_ref_size,
bool location_expression);
Expand Down
40 changes: 32 additions & 8 deletions lldb/lit/SymbolFile/DWARF/debug_loc.s
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# Test debug_loc parsing, including the cases of invalid input. The exact
# behavior in the invalid cases is not particularly important, but it should be
# "reasonable".

# REQUIRES: x86

# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
# RUN: lldb %t -o "image lookup -v -a 0" -o "image lookup -v -a 2" -o exit \
# RUN: %lldb %t -o "image lookup -v -a 0" -o "image lookup -v -a 2" -o exit \
# RUN: | FileCheck %s

# CHECK-LABEL: image lookup -v -a 0
# CHECK: Variable: {{.*}}, name = "x", type = "int", location = rdi,
# CHECK: Variable: {{.*}}, name = "x0", type = "int", location = rdi,
# CHECK: Variable: {{.*}}, name = "x1", type = "int", location = ,
# CHECK: Variable: {{.*}}, name = "x2", type = "int", location = ,

# CHECK-LABEL: image lookup -v -a 2
# CHECK: Variable: {{.*}}, name = "x", type = "int", location = rax,
# CHECK: Variable: {{.*}}, name = "x0", type = "int", location = rax,
# CHECK: Variable: {{.*}}, name = "x1", type = "int", location = ,
# CHECK: Variable: {{.*}}, name = "x2", type = "int", location = ,

.type f,@function
f: # @f
Expand All @@ -27,8 +35,12 @@ f: # @f
.asciz "f"
.Linfo_string4:
.asciz "int"
.Linfo_string5:
.asciz "x"
.Lx0:
.asciz "x0"
.Lx1:
.asciz "x1"
.Lx2:
.asciz "x2"

.section .debug_loc,"",@progbits
.Ldebug_loc0:
Expand All @@ -42,6 +54,10 @@ f: # @f
.byte 80 # super-register DW_OP_reg0
.quad 0
.quad 0
.Ldebug_loc2:
.quad .Lfunc_begin0-.Lfunc_begin0
.quad .Lfunc_end0-.Lfunc_begin0
.short 0xdead # Loc expr size

.section .debug_abbrev,"",@progbits
.byte 1 # Abbreviation Code
Expand Down Expand Up @@ -104,10 +120,18 @@ f: # @f
.quad .Lfunc_begin0 # DW_AT_low_pc
.long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
.long .Linfo_string3 # DW_AT_name
.long 83 # DW_AT_type
.byte 3 # Abbrev [3] 0x43:0xf DW_TAG_formal_parameter
.long .Lint # DW_AT_type
.byte 3 # Abbrev [3] DW_TAG_formal_parameter
.long .Ldebug_loc0 # DW_AT_location
.long .Linfo_string5 # DW_AT_name
.long .Lx0 # DW_AT_name
.long .Lint-.Lcu_begin0 # DW_AT_type
.byte 3 # Abbrev [3] DW_TAG_formal_parameter
.long 0xdeadbeef # DW_AT_location
.long .Lx1 # DW_AT_name
.long .Lint-.Lcu_begin0 # DW_AT_type
.byte 3 # Abbrev [3] DW_TAG_formal_parameter
.long .Ldebug_loc2 # DW_AT_location
.long .Lx2 # DW_AT_name
.long .Lint-.Lcu_begin0 # DW_AT_type
.byte 0 # End Of Children Mark
.Lint:
Expand Down
23 changes: 0 additions & 23 deletions lldb/source/Expression/DWARFExpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2708,29 +2708,6 @@ bool DWARFExpression::Evaluate(
return true; // Return true on success
}

size_t DWARFExpression::LocationListSize(const DWARFUnit *dwarf_cu,
const DataExtractor &debug_loc_data,
lldb::offset_t offset) {
const lldb::offset_t debug_loc_offset = offset;
while (debug_loc_data.ValidOffset(offset)) {
lldb::addr_t start_addr = LLDB_INVALID_ADDRESS;
lldb::addr_t end_addr = LLDB_INVALID_ADDRESS;
if (!AddressRangeForLocationListEntry(dwarf_cu, debug_loc_data, &offset,
start_addr, end_addr))
break;

if (start_addr == 0 && end_addr == 0)
break;

uint16_t loc_length = debug_loc_data.GetU16(&offset);
offset += loc_length;
}

if (offset > debug_loc_offset)
return offset - debug_loc_offset;
return 0;
}

bool DWARFExpression::AddressRangeForLocationListEntry(
const DWARFUnit *dwarf_cu, const DataExtractor &debug_loc_data,
lldb::offset_t *offset_ptr, lldb::addr_t &low_pc, lldb::addr_t &high_pc) {
Expand Down
7 changes: 4 additions & 3 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2186,9 +2186,10 @@ bool DWARFASTParserClang::CompleteTypeFromDWARF(const DWARFDIE &die,
std::vector<DWARFDIE> DWARFASTParserClang::GetDIEForDeclContext(
lldb_private::CompilerDeclContext decl_context) {
std::vector<DWARFDIE> result;
for (auto it = m_decl_ctx_to_die.find(
(clang::DeclContext *)decl_context.GetOpaqueDeclContext());
it != m_decl_ctx_to_die.end(); it++)
auto opaque_decl_ctx =
(clang::DeclContext *)decl_context.GetOpaqueDeclContext();
for (auto it = m_decl_ctx_to_die.find(opaque_decl_ctx);
it != m_decl_ctx_to_die.end() && it->first == opaque_decl_ctx; it++)
result.push_back(it->second);
return result;
}
Expand Down
16 changes: 5 additions & 11 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,17 +343,11 @@ bool DWARFDebugInfoEntry::GetDIENamesAndRanges(
*frame_base = DWARFExpression(
module, DataExtractor(data, block_offset, block_length), cu);
} else {
const DWARFDataExtractor &debug_loc_data = dwarf.DebugLocData();
const dw_offset_t debug_loc_offset = form_value.Unsigned();

size_t loc_list_length = DWARFExpression::LocationListSize(
cu, debug_loc_data, debug_loc_offset);
if (loc_list_length > 0) {
*frame_base = DWARFExpression(module,
DataExtractor(debug_loc_data,
debug_loc_offset,
loc_list_length),
cu);
DataExtractor data = dwarf.DebugLocData();
const dw_offset_t offset = form_value.Unsigned();
if (data.ValidOffset(offset)) {
data = DataExtractor(data, offset, data.GetByteSize() - offset);
*frame_base = DWARFExpression(module, data, cu);
if (lo_pc != LLDB_INVALID_ADDRESS) {
assert(lo_pc >= cu->GetBaseAddress());
frame_base->SetLocationListSlide(lo_pc -
Expand Down
16 changes: 5 additions & 11 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3302,17 +3302,11 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext &sc,
module, DataExtractor(data, block_offset, block_length),
die.GetCU());
} else {
const DWARFDataExtractor &debug_loc_data = DebugLocData();
const dw_offset_t debug_loc_offset = form_value.Unsigned();

size_t loc_list_length = DWARFExpression::LocationListSize(
die.GetCU(), debug_loc_data, debug_loc_offset);
if (loc_list_length > 0) {
location = DWARFExpression(module,
DataExtractor(debug_loc_data,
debug_loc_offset,
loc_list_length),
die.GetCU());
DataExtractor data = DebugLocData();
const dw_offset_t offset = form_value.Unsigned();
if (data.ValidOffset(offset)) {
data = DataExtractor(data, offset, data.GetByteSize() - offset);
location = DWARFExpression(module, data, die.GetCU());
assert(func_low_pc != LLDB_INVALID_ADDRESS);
location.SetLocationListSlide(
func_low_pc -
Expand Down
1 change: 1 addition & 0 deletions lldb/unittests/SymbolFile/DWARF/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
add_lldb_unittest(SymbolFileDWARFTests
DWARFASTParserClangTests.cpp
SymbolFileDWARFTests.cpp

LINK_LIBS
Expand Down
47 changes: 47 additions & 0 deletions lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//===-- DWARFASTParserClangTests.cpp ----------------------------*- C++ -*-===//
//
// 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 "gtest/gtest.h"

#include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h"
#include "Plugins/SymbolFile/DWARF/DWARFDIE.h"

using namespace lldb;
using namespace lldb_private;

namespace {
class DWARFASTParserClangStub : public DWARFASTParserClang {
public:
using DWARFASTParserClang::DWARFASTParserClang;
using DWARFASTParserClang::LinkDeclContextToDIE;
};
} // namespace

// If your implementation needs to dereference the dummy pointers we are
// defining here, causing this test to fail, feel free to delete it.
TEST(DWARFASTParserClangTests,
TestGetDIEForDeclContextReturnsOnlyMatchingEntries) {
ClangASTContext ast_ctx;
DWARFASTParserClangStub ast_parser(ast_ctx);

DWARFUnit *unit = nullptr;
DWARFDIE die1(unit, (DWARFDebugInfoEntry *)1LL);
DWARFDIE die2(unit, (DWARFDebugInfoEntry *)2LL);
DWARFDIE die3(unit, (DWARFDebugInfoEntry *)3LL);
DWARFDIE die4(unit, (DWARFDebugInfoEntry *)4LL);
ast_parser.LinkDeclContextToDIE((clang::DeclContext *)1LL, die1);
ast_parser.LinkDeclContextToDIE((clang::DeclContext *)2LL, die2);
ast_parser.LinkDeclContextToDIE((clang::DeclContext *)2LL, die3);
ast_parser.LinkDeclContextToDIE((clang::DeclContext *)3LL, die4);

auto die_list = ast_parser.GetDIEForDeclContext(
CompilerDeclContext(nullptr, (clang::DeclContext *)2LL));
ASSERT_EQ(2u, die_list.size());
ASSERT_EQ(die2, die_list[0]);
ASSERT_EQ(die3, die_list[1]);
}
Loading