Skip to content

Commit 1bb6e4d

Browse files
committed
remove dead CreateSource version, move IsAssemblySource to ProtocolUtils.cpp
1 parent 43ec346 commit 1bb6e4d

File tree

8 files changed

+48
-23
lines changed

8 files changed

+48
-23
lines changed

lldb/tools/lldb-dap/Breakpoint.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "Breakpoint.h"
1010
#include "DAP.h"
1111
#include "JSONUtils.h"
12+
#include "Protocol/ProtocolUtils.h"
1213
#include "lldb/API/SBAddress.h"
1314
#include "lldb/API/SBBreakpointLocation.h"
1415
#include "lldb/API/SBLineEntry.h"
@@ -65,7 +66,7 @@ protocol::Breakpoint Breakpoint::ToProtocolBreakpoint() {
6566
breakpoint.instructionReference = formatted_addr;
6667

6768
auto source = CreateSource(bp_addr, m_dap.target);
68-
if (!source.IsAssemblySource()) {
69+
if (!IsAssemblySource(source)) {
6970
auto line_entry = bp_addr.GetLineEntry();
7071
const auto line = line_entry.GetLine();
7172
if (line != LLDB_INVALID_LINE_NUMBER)

lldb/tools/lldb-dap/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ add_lldb_library(lldbDAP
6868
Protocol/ProtocolBase.cpp
6969
Protocol/ProtocolTypes.cpp
7070
Protocol/ProtocolRequests.cpp
71+
Protocol/ProtocolUtils.cpp
7172

7273
LINK_LIBS
7374
liblldb

lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "LLDBUtils.h"
1313
#include "Protocol/ProtocolRequests.h"
1414
#include "Protocol/ProtocolTypes.h"
15+
#include "Protocol/ProtocolUtils.h"
1516
#include "RequestHandler.h"
1617
#include "lldb/API/SBAddress.h"
1718
#include "lldb/API/SBInstruction.h"
@@ -145,7 +146,7 @@ static DisassembledInstruction ConvertSBInstructionToDisassembledInstruction(
145146

146147
// If the line number is 0 then the entry represents a compiler generated
147148
// location.
148-
if (!source.IsAssemblySource() && line_entry.IsValid() &&
149+
if (!IsAssemblySource(source) && line_entry.IsValid() &&
149150
line_entry.GetStartAddress() == addr && line_entry.IsValid() &&
150151
line_entry.GetFileSpec().IsValid() && line_entry.GetLine() != 0) {
151152

lldb/tools/lldb-dap/JSONUtils.cpp

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "DAP.h"
1111
#include "ExceptionBreakpoint.h"
1212
#include "LLDBUtils.h"
13+
#include "Protocol/ProtocolUtils.h"
1314
#include "lldb/API/SBAddress.h"
1415
#include "lldb/API/SBCompileUnit.h"
1516
#include "lldb/API/SBDebugger.h"
@@ -584,14 +585,6 @@ protocol::Source CreateSource(lldb::SBAddress address, lldb::SBTarget &target) {
584585
return CreateAssemblySource(target, address);
585586
}
586587

587-
protocol::Source CreateSource(llvm::StringRef source_path) {
588-
protocol::Source source;
589-
llvm::StringRef name = llvm::sys::path::filename(source_path);
590-
source.name = name;
591-
source.path = source_path;
592-
return source;
593-
}
594-
595588
// "StackFrame": {
596589
// "type": "object",
597590
// "description": "A Stackframe contains the source location.",
@@ -684,7 +677,7 @@ llvm::json::Value CreateStackFrame(lldb::SBFrame &frame,
684677

685678
auto target = frame.GetThread().GetProcess().GetTarget();
686679
auto source = CreateSource(frame.GetPCAddress(), target);
687-
if (!source.IsAssemblySource()) {
680+
if (!IsAssemblySource(source)) {
688681
// This is a normal source with a valid line entry.
689682
auto line_entry = frame.GetLineEntry();
690683
object.try_emplace("line", line_entry.GetLine());

lldb/tools/lldb-dap/JSONUtils.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,6 @@ protocol::Source CreateSource(const lldb::SBFileSpec &file);
263263
/// definition outlined by Microsoft.
264264
protocol::Source CreateSource(lldb::SBAddress address, lldb::SBTarget &target);
265265

266-
/// Create a "Source" object for a given source path.
267-
///
268-
/// \param[in] source_path
269-
/// The path to the source to use when creating the "Source" object.
270-
///
271-
/// \return
272-
/// A "Source" JSON object that follows the formal JSON
273-
/// definition outlined by Microsoft.
274-
protocol::Source CreateSource(llvm::StringRef source_path);
275-
276266
/// Create a "StackFrame" object for a LLDB frame object.
277267
///
278268
/// This function will fill in the following keys in the returned

lldb/tools/lldb-dap/Protocol/ProtocolTypes.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,6 @@ struct Source {
317317
std::optional<PresentationHint> presentationHint;
318318

319319
// unsupported keys: origin, sources, adapterData, checksums
320-
321-
bool IsAssemblySource() const { return sourceReference.value_or(0) != 0; }
322320
};
323321
bool fromJSON(const llvm::json::Value &, Source::PresentationHint &,
324322
llvm::json::Path);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//===-- ProtocolUtils.cpp -------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "Protocol/ProtocolUtils.h"
10+
11+
namespace lldb_dap::protocol {
12+
13+
bool IsAssemblySource(const protocol::Source &source) {
14+
return source.sourceReference.value_or(0) != 0;
15+
}
16+
17+
} // namespace lldb_dap::protocol
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===-- ProtocolUtils.h ---------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file contains Utility function for protocol objects.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLDB_TOOLS_LLDB_DAP_PROTOCOL_PROTOCOL_UTILS_H
14+
#define LLDB_TOOLS_LLDB_DAP_PROTOCOL_PROTOCOL_UTILS_H
15+
16+
#include "Protocol/ProtocolTypes.h"
17+
18+
namespace lldb_dap::protocol {
19+
20+
bool IsAssemblySource(const protocol::Source &source);
21+
22+
} // namespace lldb_dap::protocol
23+
24+
#endif

0 commit comments

Comments
 (0)