Skip to content

Commit 77374d3

Browse files
committed
[lldb] Move ScriptInterpreter Interfaces to subdirectory (NFC)
As we're consolidating and streamlining the various scripting affordances of lldb, we keep creating new interface files. This patch groups all the current interface files into a separate sub directory called `Interfaces` both in the core `Interpreter` directory and the `ScriptInterpreter` plugin directory. Differential Revision: https://reviews.llvm.org/D158833 Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 0c93589 commit 77374d3

17 files changed

+151
-81
lines changed

lldb/include/lldb/Interpreter/ScriptedInterface.h renamed to lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
10-
#define LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
9+
#ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDINTERFACE_H
10+
#define LLDB_INTERPRETER_INTERFACES_SCRIPTEDINTERFACE_H
1111

1212
#include "lldb/Core/StructuredDataImpl.h"
1313
#include "lldb/Target/ExecutionContext.h"
@@ -74,4 +74,4 @@ class ScriptedInterface {
7474
StructuredData::GenericSP m_object_instance_sp;
7575
};
7676
} // namespace lldb_private
77-
#endif // LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
77+
#endif // LLDB_INTERPRETER_INTERFACES_SCRIPTEDINTERFACE_H

lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h renamed to lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLDB_INTERPRETER_SCRIPTEDPLATFORMINTERFACE_H
10-
#define LLDB_INTERPRETER_SCRIPTEDPLATFORMINTERFACE_H
9+
#ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDPLATFORMINTERFACE_H
10+
#define LLDB_INTERPRETER_INTERFACES_SCRIPTEDPLATFORMINTERFACE_H
1111

1212
#include "lldb/Core/StructuredDataImpl.h"
13-
#include "lldb/Interpreter/ScriptedInterface.h"
13+
#include "lldb/Interpreter/Interfaces/ScriptedInterface.h"
1414

1515
#include "lldb/lldb-private.h"
1616

@@ -46,4 +46,4 @@ class ScriptedPlatformInterface : virtual public ScriptedInterface {
4646
};
4747
} // namespace lldb_private
4848

49-
#endif // LLDB_INTERPRETER_SCRIPTEDPLATFORMINTERFACE_H
49+
#endif // LLDB_INTERPRETER_INTERFACES_SCRIPTEDPLATFORMINTERFACE_H

lldb/include/lldb/Interpreter/ScriptedProcessInterface.h renamed to lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h

Lines changed: 4 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLDB_INTERPRETER_SCRIPTEDPROCESSINTERFACE_H
10-
#define LLDB_INTERPRETER_SCRIPTEDPROCESSINTERFACE_H
9+
#ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDPROCESSINTERFACE_H
10+
#define LLDB_INTERPRETER_INTERFACES_SCRIPTEDPROCESSINTERFACE_H
1111

12+
#include "ScriptedInterface.h"
1213
#include "lldb/Core/StructuredDataImpl.h"
13-
#include "lldb/Interpreter/ScriptedInterface.h"
1414
#include "lldb/Target/MemoryRegionInfo.h"
1515

1616
#include "lldb/lldb-private.h"
@@ -80,36 +80,6 @@ class ScriptedProcessInterface : virtual public ScriptedInterface {
8080
return {};
8181
}
8282
};
83-
84-
class ScriptedThreadInterface : virtual public ScriptedInterface {
85-
public:
86-
StructuredData::GenericSP
87-
CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
88-
StructuredData::DictionarySP args_sp,
89-
StructuredData::Generic *script_obj = nullptr) override {
90-
return {};
91-
}
92-
93-
virtual lldb::tid_t GetThreadID() { return LLDB_INVALID_THREAD_ID; }
94-
95-
virtual std::optional<std::string> GetName() { return std::nullopt; }
96-
97-
virtual lldb::StateType GetState() { return lldb::eStateInvalid; }
98-
99-
virtual std::optional<std::string> GetQueue() { return std::nullopt; }
100-
101-
virtual StructuredData::DictionarySP GetStopReason() { return {}; }
102-
103-
virtual StructuredData::ArraySP GetStackFrames() { return {}; }
104-
105-
virtual StructuredData::DictionarySP GetRegisterInfo() { return {}; }
106-
107-
virtual std::optional<std::string> GetRegisterContext() {
108-
return std::nullopt;
109-
}
110-
111-
virtual StructuredData::ArraySP GetExtendedInfo() { return {}; }
112-
};
11383
} // namespace lldb_private
11484

115-
#endif // LLDB_INTERPRETER_SCRIPTEDPROCESSINTERFACE_H
85+
#endif // LLDB_INTERPRETER_INTERFACES_SCRIPTEDPROCESSINTERFACE_H
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//===-- ScriptedThreadInterface.h -------------------------------*- C++ -*-===//
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+
#ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDTHREADINTERFACE_H
10+
#define LLDB_INTERPRETER_INTERFACES_SCRIPTEDTHREADINTERFACE_H
11+
12+
#include "ScriptedInterface.h"
13+
#include "lldb/Core/StructuredDataImpl.h"
14+
15+
#include "lldb/lldb-private.h"
16+
17+
#include <optional>
18+
#include <string>
19+
20+
namespace lldb_private {
21+
class ScriptedThreadInterface : virtual public ScriptedInterface {
22+
public:
23+
StructuredData::GenericSP
24+
CreatePluginObject(llvm::StringRef class_name, ExecutionContext &exe_ctx,
25+
StructuredData::DictionarySP args_sp,
26+
StructuredData::Generic *script_obj = nullptr) override {
27+
return {};
28+
}
29+
30+
virtual lldb::tid_t GetThreadID() { return LLDB_INVALID_THREAD_ID; }
31+
32+
virtual std::optional<std::string> GetName() { return std::nullopt; }
33+
34+
virtual lldb::StateType GetState() { return lldb::eStateInvalid; }
35+
36+
virtual std::optional<std::string> GetQueue() { return std::nullopt; }
37+
38+
virtual StructuredData::DictionarySP GetStopReason() { return {}; }
39+
40+
virtual StructuredData::ArraySP GetStackFrames() { return {}; }
41+
42+
virtual StructuredData::DictionarySP GetRegisterInfo() { return {}; }
43+
44+
virtual std::optional<std::string> GetRegisterContext() {
45+
return std::nullopt;
46+
}
47+
48+
virtual StructuredData::ArraySP GetExtendedInfo() { return {}; }
49+
};
50+
} // namespace lldb_private
51+
52+
#endif // LLDB_INTERPRETER_INTERFACES_SCRIPTEDTHREADINTERFACE_H

lldb/include/lldb/Interpreter/ScriptInterpreter.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
#include "lldb/Core/ThreadedCommunication.h"
2222
#include "lldb/Host/PseudoTerminal.h"
2323
#include "lldb/Host/StreamFile.h"
24+
#include "lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h"
25+
#include "lldb/Interpreter/Interfaces/ScriptedProcessInterface.h"
26+
#include "lldb/Interpreter/Interfaces/ScriptedThreadInterface.h"
2427
#include "lldb/Interpreter/ScriptObject.h"
25-
#include "lldb/Interpreter/ScriptedPlatformInterface.h"
26-
#include "lldb/Interpreter/ScriptedProcessInterface.h"
2728
#include "lldb/Utility/Broadcaster.h"
2829
#include "lldb/Utility/Status.h"
2930
#include "lldb/Utility/StructuredData.h"
@@ -588,6 +589,10 @@ class ScriptInterpreter : public PluginInterface {
588589
return std::make_unique<ScriptedProcessInterface>();
589590
}
590591

592+
virtual lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() {
593+
return std::make_shared<ScriptedThreadInterface>();
594+
}
595+
591596
ScriptedPlatformInterface &GetScriptedPlatformInterface() {
592597
return *m_scripted_platform_interface_up;
593598
}

lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@ if (LLDB_ENABLE_LIBEDIT)
1919
list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit)
2020
endif()
2121

22+
add_subdirectory(Interfaces)
23+
2224
add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
2325
PythonDataObjects.cpp
2426
PythonReadline.cpp
2527
ScriptInterpreterPython.cpp
26-
ScriptedPythonInterface.cpp
27-
ScriptedProcessPythonInterface.cpp
28-
ScriptedThreadPythonInterface.cpp
29-
ScriptedPlatformPythonInterface.cpp
3028

3129
LINK_LIBS
3230
lldbBreakpoint
@@ -35,6 +33,7 @@ add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
3533
lldbHost
3634
lldbInterpreter
3735
lldbTarget
36+
lldbPluginScriptInterpreterPythonInterfaces
3837
${Python3_LIBRARIES}
3938
${LLDB_LIBEDIT_LIBS}
4039

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
if (APPLE AND LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY)
2+
# Work around an issue with the Python headers, which have a modular include
3+
# inside an extern "C" block.
4+
remove_module_flags()
5+
endif()
6+
7+
if(NOT LLDB_PYTHON_RELATIVE_PATH)
8+
message(FATAL_ERROR "LLDB_PYTHON_RELATIVE_PATH is not set.")
9+
endif()
10+
add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${LLDB_PYTHON_RELATIVE_PATH}")
11+
12+
if(NOT LLDB_PYTHON_EXE_RELATIVE_PATH)
13+
message(FATAL_ERROR "LLDB_PYTHON_EXE_RELATIVE_PATH is not set.")
14+
endif()
15+
add_definitions(-DLLDB_PYTHON_EXE_RELATIVE_PATH="${LLDB_PYTHON_EXE_RELATIVE_PATH}")
16+
17+
18+
if (LLDB_ENABLE_LIBEDIT)
19+
list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit)
20+
endif()
21+
22+
add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces
23+
ScriptedPythonInterface.cpp
24+
ScriptedProcessPythonInterface.cpp
25+
ScriptedThreadPythonInterface.cpp
26+
ScriptedPlatformPythonInterface.cpp
27+
28+
LINK_LIBS
29+
lldbCore
30+
lldbHost
31+
lldbInterpreter
32+
lldbTarget
33+
${Python3_LIBRARIES}
34+
${LLDB_LIBEDIT_LIBS}
35+
36+
LINK_COMPONENTS
37+
Support
38+
)

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp renamed to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
#if LLDB_ENABLE_PYTHON
1515

1616
// LLDB Python header must be included first
17-
#include "lldb-python.h"
17+
#include "../lldb-python.h"
1818

19-
#include "SWIGPythonBridge.h"
20-
#include "ScriptInterpreterPythonImpl.h"
19+
#include "../SWIGPythonBridge.h"
20+
#include "../ScriptInterpreterPythonImpl.h"
2121
#include "ScriptedPlatformPythonInterface.h"
2222

2323
using namespace lldb;

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.h renamed to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPLATFORMPYTHONINTERFACE_H
10-
#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPLATFORMPYTHONINTERFACE_H
9+
#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPLATFORMPYTHONINTERFACE_H
10+
#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPLATFORMPYTHONINTERFACE_H
1111

1212
#include "lldb/Host/Config.h"
1313

1414
#if LLDB_ENABLE_PYTHON
1515

1616
#include "ScriptedPythonInterface.h"
17-
#include "lldb/Interpreter/ScriptedPlatformInterface.h"
17+
#include "lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h"
1818

1919
namespace lldb_private {
2020
class ScriptedPlatformPythonInterface : public ScriptedPlatformInterface,
@@ -41,4 +41,4 @@ class ScriptedPlatformPythonInterface : public ScriptedPlatformInterface,
4141
} // namespace lldb_private
4242

4343
#endif // LLDB_ENABLE_PYTHON
44-
#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPLATFORMPYTHONINTERFACE_H
44+
#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPLATFORMPYTHONINTERFACE_H

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp renamed to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "lldb/Host/Config.h"
1010
#if LLDB_ENABLE_PYTHON
1111
// LLDB Python header must be included first
12-
#include "lldb-python.h"
12+
#include "../lldb-python.h"
1313
#endif
1414
#include "lldb/Target/Process.h"
1515
#include "lldb/Utility/Log.h"
@@ -18,8 +18,8 @@
1818

1919
#if LLDB_ENABLE_PYTHON
2020

21-
#include "SWIGPythonBridge.h"
22-
#include "ScriptInterpreterPythonImpl.h"
21+
#include "../SWIGPythonBridge.h"
22+
#include "../ScriptInterpreterPythonImpl.h"
2323
#include "ScriptedProcessPythonInterface.h"
2424
#include "ScriptedThreadPythonInterface.h"
2525
#include <optional>
@@ -199,7 +199,7 @@ ScriptedProcessPythonInterface::GetScriptedThreadPluginName() {
199199

200200
lldb::ScriptedThreadInterfaceSP
201201
ScriptedProcessPythonInterface::CreateScriptedThreadInterface() {
202-
return std::make_shared<ScriptedThreadPythonInterface>(m_interpreter);
202+
return m_interpreter.CreateScriptedThreadInterface();
203203
}
204204

205205
StructuredData::DictionarySP ScriptedProcessPythonInterface::GetMetadata() {

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h renamed to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H
10-
#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H
9+
#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPROCESSPYTHONINTERFACE_H
10+
#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPROCESSPYTHONINTERFACE_H
1111

1212
#include "lldb/Host/Config.h"
1313

1414
#if LLDB_ENABLE_PYTHON
1515

1616
#include "ScriptedPythonInterface.h"
17-
#include "lldb/Interpreter/ScriptedProcessInterface.h"
17+
#include "lldb/Interpreter/Interfaces/ScriptedProcessInterface.h"
1818
#include <optional>
1919

2020
namespace lldb_private {
@@ -68,4 +68,4 @@ class ScriptedProcessPythonInterface : public ScriptedProcessInterface,
6868
} // namespace lldb_private
6969

7070
#endif // LLDB_ENABLE_PYTHON
71-
#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPROCESSPYTHONINTERFACE_H
71+
#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPROCESSPYTHONINTERFACE_H

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp renamed to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#if LLDB_ENABLE_PYTHON
1414

1515
// LLDB Python header must be included first
16-
#include "lldb-python.h"
16+
#include "../lldb-python.h"
1717

18-
#include "ScriptInterpreterPythonImpl.h"
18+
#include "../ScriptInterpreterPythonImpl.h"
1919
#include "ScriptedPythonInterface.h"
2020
#include <optional>
2121

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h renamed to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPYTHONINTERFACE_H
10-
#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPYTHONINTERFACE_H
9+
#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPYTHONINTERFACE_H
10+
#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPYTHONINTERFACE_H
1111

1212
#if LLDB_ENABLE_PYTHON
1313

@@ -18,12 +18,12 @@
1818
#include <utility>
1919

2020
#include "lldb/Host/Config.h"
21-
#include "lldb/Interpreter/ScriptedInterface.h"
21+
#include "lldb/Interpreter/Interfaces/ScriptedInterface.h"
2222
#include "lldb/Utility/DataBufferHeap.h"
2323

24-
#include "PythonDataObjects.h"
25-
#include "SWIGPythonBridge.h"
26-
#include "ScriptInterpreterPythonImpl.h"
24+
#include "../PythonDataObjects.h"
25+
#include "../SWIGPythonBridge.h"
26+
#include "../ScriptInterpreterPythonImpl.h"
2727

2828
namespace lldb_private {
2929
class ScriptInterpreterPythonImpl;
@@ -146,7 +146,6 @@ class ScriptedPythonInterface : virtual public ScriptedInterface {
146146
original_arg = ExtractValueFromPythonObject<T>(transformed_arg, error);
147147
}
148148

149-
150149
void ReverseTransform(bool &original_arg,
151150
python::PythonObject transformed_arg, Status &error) {
152151
python::PythonBoolean boolean_arg = python::PythonBoolean(
@@ -254,4 +253,4 @@ ScriptedPythonInterface::ExtractValueFromPythonObject<
254253
} // namespace lldb_private
255254

256255
#endif // LLDB_ENABLE_PYTHON
257-
#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDPYTHONINTERFACE_H
256+
#endif // LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_INTERFACES_SCRIPTEDPYTHONINTERFACE_H

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp renamed to lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
#if LLDB_ENABLE_PYTHON
1414

1515
// LLDB Python header must be included first
16-
#include "lldb-python.h"
16+
#include "../lldb-python.h"
1717

18-
#include "SWIGPythonBridge.h"
19-
#include "ScriptInterpreterPythonImpl.h"
18+
#include "../SWIGPythonBridge.h"
19+
#include "../ScriptInterpreterPythonImpl.h"
2020
#include "ScriptedThreadPythonInterface.h"
2121
#include <optional>
2222

0 commit comments

Comments
 (0)