Skip to content

Commit a338c11

Browse files
Merge pull request #8885 from adrian-prantl/cherry-pick-sblang
Cherry pick SBSourceLanguage
2 parents 24dd718 + 40d2d29 commit a338c11

File tree

70 files changed

+947
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+947
-186
lines changed

lldb/bindings/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ file(GLOB_RECURSE SWIG_SOURCES *.swig)
33
file(GLOB SWIG_HEADERS
44
${LLDB_SOURCE_DIR}/include/lldb/API/*.h
55
${LLDB_SOURCE_DIR}/include/lldb/*.h
6+
${LLDB_BINARY_DIR}/include/lldb/API/SBLanguages.h
67
)
78
file(GLOB SWIG_PRIVATE_HEADERS
89
${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h
@@ -36,6 +37,7 @@ set(SWIG_COMMON_FLAGS
3637
-w361,362,509
3738
-features autodoc
3839
-I${LLDB_SOURCE_DIR}/include
40+
-I${LLDB_BINARY_DIR}/include
3941
-I${CMAKE_CURRENT_SOURCE_DIR}
4042
${DARWIN_EXTRAS}
4143
)

lldb/bindings/headers.swig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "lldb/API/SBHostOS.h"
3737
#include "lldb/API/SBInstruction.h"
3838
#include "lldb/API/SBInstructionList.h"
39+
#include "lldb/API/SBLanguages.h"
3940
#include "lldb/API/SBLanguageRuntime.h"
4041
#include "lldb/API/SBLaunchInfo.h"
4142
#include "lldb/API/SBLineEntry.h"

lldb/bindings/interfaces.swig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
%include "lldb/API/SBHostOS.h"
115115
%include "lldb/API/SBInstruction.h"
116116
%include "lldb/API/SBInstructionList.h"
117+
%include "lldb/API/SBLanguages.h"
117118
%include "lldb/API/SBLanguageRuntime.h"
118119
%include "lldb/API/SBLaunchInfo.h"
119120
%include "lldb/API/SBLineEntry.h"

lldb/bindings/lua/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ else()
1010
DEPENDS ${SWIG_SOURCES}
1111
DEPENDS ${SWIG_INTERFACES}
1212
DEPENDS ${SWIG_HEADERS}
13+
DEPENDS lldb-sbapi-dwarf-enums
1314
COMMAND ${SWIG_EXECUTABLE}
1415
${SWIG_COMMON_FLAGS}
1516
-I${CMAKE_CURRENT_SOURCE_DIR}

lldb/bindings/python/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ add_custom_command(
1111
DEPENDS ${SWIG_SOURCES}
1212
DEPENDS ${SWIG_INTERFACES}
1313
DEPENDS ${SWIG_HEADERS}
14+
DEPENDS lldb-sbapi-dwarf-enums
1415
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/prepare_binding_python.py
1516
COMMAND ${Python3_EXECUTABLE} ${LLDB_SOURCE_DIR}/bindings/prepare_bindings.py
1617
${framework_arg}

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set(LLDB_INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include")
77

88
set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
99
set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
10+
set(LLDB_OBJ_DIR ${CMAKE_CURRENT_BINARY_DIR})
1011

1112
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
1213
message(FATAL_ERROR

lldb/cmake/modules/LLDBFramework.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ endif()
7171
# At configuration time, collect headers for the framework bundle and copy them
7272
# into a staging directory. Later we can copy over the entire folder.
7373
file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
74+
set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h)
7475
file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
7576
file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
7677
list(REMOVE_ITEM root_public_headers ${root_private_headers})
@@ -80,6 +81,7 @@ find_program(unifdef_EXECUTABLE unifdef)
8081
set(lldb_header_staging ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders)
8182
foreach(header
8283
${public_headers}
84+
${generated_public_headers}
8385
${root_public_headers})
8486

8587
get_filename_component(basename ${header} NAME)
@@ -103,7 +105,7 @@ foreach(header
103105
endforeach()
104106

105107
# Wrap output in a target, so lldb-framework can depend on it.
106-
add_custom_target(liblldb-resource-headers DEPENDS ${lldb_staged_headers})
108+
add_custom_target(liblldb-resource-headers DEPENDS lldb-sbapi-dwarf-enums ${lldb_staged_headers})
107109
set_target_properties(liblldb-resource-headers PROPERTIES FOLDER "lldb misc")
108110
add_dependencies(liblldb liblldb-resource-headers)
109111

lldb/include/lldb/API/LLDB.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "lldb/API/SBInstruction.h"
4141
#include "lldb/API/SBInstructionList.h"
4242
#include "lldb/API/SBLanguageRuntime.h"
43+
#include "lldb/API/SBLanguages.h"
4344
#include "lldb/API/SBLaunchInfo.h"
4445
#include "lldb/API/SBLineEntry.h"
4546
#include "lldb/API/SBListener.h"

lldb/include/lldb/API/SBExpressionOptions.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLDB_API_SBEXPRESSIONOPTIONS_H
1111

1212
#include "lldb/API/SBDefines.h"
13+
#include "lldb/API/SBLanguages.h"
1314

1415
#include <vector>
1516

@@ -67,6 +68,10 @@ class LLDB_API SBExpressionOptions {
6768
void SetTrapExceptions(bool trap_exceptions = true);
6869

6970
void SetLanguage(lldb::LanguageType language);
71+
/// Set the language using a pair of language code and version as
72+
/// defined by the DWARF 6 specification.
73+
/// WARNING: These codes may change until DWARF 6 is finalized.
74+
void SetLanguage(SBSourceLanguageName name, uint32_t version);
7075

7176
#ifndef SWIG
7277
void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);

lldb/include/lldb/Expression/Expression.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,8 @@ class Expression {
4747
/// expression. Text() should contain the definition of this function.
4848
virtual const char *FunctionName() = 0;
4949

50-
/// Return the language that should be used when parsing. To use the
51-
/// default, return eLanguageTypeUnknown.
52-
virtual lldb::LanguageType Language() const {
53-
return lldb::eLanguageTypeUnknown;
54-
}
50+
/// Return the language that should be used when parsing.
51+
virtual SourceLanguage Language() const { return {}; }
5552

5653
/// Return the Materializer that the parser should use when registering
5754
/// external values.

lldb/include/lldb/Expression/LLVMUserExpression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class LLVMUserExpression : public UserExpression {
5252
};
5353

5454
LLVMUserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
55-
llvm::StringRef prefix, lldb::LanguageType language,
55+
llvm::StringRef prefix, SourceLanguage language,
5656
ResultType desired_type,
5757
const EvaluateExpressionOptions &options);
5858
~LLVMUserExpression() override;

lldb/include/lldb/Expression/UserExpression.h

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class UserExpression : public Expression {
5656
/// If not eResultTypeAny, the type to use for the expression
5757
/// result.
5858
UserExpression(ExecutionContextScope &exe_scope, llvm::StringRef expr,
59-
llvm::StringRef prefix, lldb::LanguageType language,
59+
llvm::StringRef prefix, SourceLanguage language,
6060
ResultType desired_type,
6161
const EvaluateExpressionOptions &options);
6262

@@ -201,7 +201,7 @@ class UserExpression : public Expression {
201201
virtual bool IsParseCacheable() { return true; }
202202
/// Return the language that should be used when parsing. To use the
203203
/// default, return eLanguageTypeUnknown.
204-
lldb::LanguageType Language() const override { return m_language; }
204+
SourceLanguage Language() const override { return m_language; }
205205

206206
/// Return the desired result type of the function, or eResultTypeAny if
207207
/// indifferent.
@@ -314,19 +314,22 @@ class UserExpression : public Expression {
314314
lldb::ProcessSP &process_sp,
315315
lldb::StackFrameSP &frame_sp);
316316

317-
Address m_address; ///< The address the process is stopped in.
318-
std::string m_expr_text; ///< The text of the expression, as typed by the user
319-
std::string m_expr_prefix; ///< The text of the translation-level definitions,
320-
///as provided by the user
321-
std::string m_fixed_text; ///< The text of the expression with fix-its applied
322-
///- this won't be set if the fixed text doesn't
323-
///parse.
324-
lldb::LanguageType m_language; ///< The language to use when parsing
325-
///(eLanguageTypeUnknown means use defaults)
326-
ResultType m_desired_type; ///< The type to coerce the expression's result to.
327-
///If eResultTypeAny, inferred from the expression.
328-
EvaluateExpressionOptions
329-
m_options; ///< Additional options provided by the user.
317+
/// The address the process is stopped in.
318+
Address m_address;
319+
/// The text of the expression, as typed by the user.
320+
std::string m_expr_text;
321+
/// The text of the translation-level definitions, as provided by the user.
322+
std::string m_expr_prefix;
323+
/// The text of the expression with fix-its applied this won't be set if the
324+
/// fixed text doesn't parse.
325+
std::string m_fixed_text;
326+
/// The language to use when parsing (unknown means use defaults).
327+
SourceLanguage m_language;
328+
/// The type to coerce the expression's result to. If eResultTypeAny, inferred
329+
/// from the expression.
330+
ResultType m_desired_type;
331+
/// Additional options provided by the user.
332+
EvaluateExpressionOptions m_options;
330333
};
331334

332335
} // namespace lldb_private

lldb/include/lldb/Symbol/TypeSystem.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -501,12 +501,10 @@ class TypeSystem : public PluginInterface,
501501
return IsPointerOrReferenceType(type, nullptr);
502502
}
503503

504-
virtual UserExpression *
505-
GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
506-
lldb::LanguageType language,
507-
Expression::ResultType desired_type,
508-
const EvaluateExpressionOptions &options,
509-
ValueObject *ctx_obj) {
504+
virtual UserExpression *GetUserExpression(
505+
llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language,
506+
Expression::ResultType desired_type,
507+
const EvaluateExpressionOptions &options, ValueObject *ctx_obj) {
510508
return nullptr;
511509
}
512510

lldb/include/lldb/Target/StackFrame.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
//===-- StackFrame.h --------------------------------------------*- C++ -*-===//
23
//
34
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -446,13 +447,12 @@ class StackFrame : public ExecutionContextScope,
446447
/// Query this frame to determine what the default language should be when
447448
/// parsing expressions given the execution context.
448449
///
449-
/// \return
450-
/// The language of the frame if known, else lldb::eLanguageTypeUnknown.
451-
lldb::LanguageType GetLanguage();
450+
/// \return The language of the frame if known.
451+
SourceLanguage GetLanguage();
452452

453-
// similar to GetLanguage(), but is allowed to take a potentially incorrect
454-
// guess if exact information is not available
455-
lldb::LanguageType GuessLanguage();
453+
/// Similar to GetLanguage(), but is allowed to take a potentially incorrect
454+
/// guess if exact information is not available.
455+
SourceLanguage GuessLanguage();
456456

457457
/// Attempt to econstruct the ValueObject for a given raw address touched by
458458
/// the current instruction. The ExpressionPath should indicate how to get

lldb/include/lldb/Target/Target.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ class TargetProperties : public Properties {
174174

175175
llvm::StringRef GetSwiftExtraClangFlags() const;
176176

177+
llvm::StringRef GetSwiftClangOverrideOptions() const;
178+
177179
bool GetSwiftReadMetadataFromFileCache() const;
178180

179181
bool GetSwiftUseReflectionSymbols() const;
@@ -243,7 +245,7 @@ class TargetProperties : public Properties {
243245

244246
bool GetBreakpointsConsultPlatformAvoidList();
245247

246-
lldb::LanguageType GetLanguage() const;
248+
SourceLanguage GetLanguage() const;
247249

248250
llvm::StringRef GetExpressionPrefixContents();
249251

@@ -359,9 +361,18 @@ class EvaluateExpressionOptions {
359361
m_execution_policy = policy;
360362
}
361363

362-
lldb::LanguageType GetLanguage() const { return m_language; }
364+
SourceLanguage GetLanguage() const { return m_language; }
365+
366+
void SetLanguage(lldb::LanguageType language_type) {
367+
m_language = SourceLanguage(language_type);
368+
}
363369

364-
void SetLanguage(lldb::LanguageType language) { m_language = language; }
370+
/// Set the language using a pair of language code and version as
371+
/// defined by the DWARF 6 specification.
372+
/// WARNING: These codes may change until DWARF 6 is finalized.
373+
void SetLanguage(uint16_t name, uint32_t version) {
374+
m_language = SourceLanguage(name, version);
375+
}
365376

366377
bool DoesCoerceToId() const { return m_coerce_to_id; }
367378

@@ -524,7 +535,7 @@ class EvaluateExpressionOptions {
524535

525536
private:
526537
ExecutionPolicy m_execution_policy = default_execution_policy;
527-
lldb::LanguageType m_language = lldb::eLanguageTypeUnknown;
538+
SourceLanguage m_language;
528539
std::string m_prefix;
529540
bool m_coerce_to_id = false;
530541
bool m_unwind_on_error = true;
@@ -1255,7 +1266,7 @@ class Target : public std::enable_shared_from_this<Target>,
12551266

12561267
UserExpression *
12571268
GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix,
1258-
lldb::LanguageType language,
1269+
SourceLanguage language,
12591270
Expression::ResultType desired_type,
12601271
const EvaluateExpressionOptions &options,
12611272
ValueObject *ctx_obj, Status &error);

lldb/include/lldb/Target/ThreadPlanCallFunction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class ThreadPlanCallFunction : public ThreadPlan {
9797

9898
virtual void SetStopOthers(bool new_value) override;
9999

100-
lldb::LanguageType GetExpressionLanguage() { return m_expression_language; }
100+
SourceLanguage GetExpressionLanguage() { return m_expression_language; }
101101

102102
bool HitErrorBackstop() { return m_hit_error_backstop; }
103103

@@ -148,7 +148,7 @@ class ThreadPlanCallFunction : public ThreadPlan {
148148
bool m_should_clear_cxx_exception_bp;
149149
lldb::addr_t m_stop_address; // This is the address we stopped at. Also set
150150
// in DoTakedown;
151-
lldb::LanguageType
151+
SourceLanguage
152152
m_expression_language; // Set from the incoming ExpressionOptions.
153153
lldb::BreakpointSP m_error_backstop_bp_sp;
154154
bool m_hit_error_backstop;

lldb/include/lldb/lldb-private-types.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,25 @@ struct RegisterSet {
9696
const uint32_t *registers;
9797
};
9898

99+
/// A type-erased pair of llvm::dwarf::SourceLanguageName and version.
100+
struct SourceLanguage {
101+
SourceLanguage() = default;
102+
SourceLanguage(lldb::LanguageType language_type);
103+
SourceLanguage(uint16_t name, uint32_t version)
104+
: name(name), version(version) {}
105+
SourceLanguage(std::optional<std::pair<uint16_t, uint32_t>> name_vers)
106+
: name(name_vers ? name_vers->first : 0),
107+
version(name_vers ? name_vers->second : 0) {}
108+
operator bool() const { return name > 0; }
109+
lldb::LanguageType AsLanguageType() const;
110+
llvm::StringRef GetDescription() const;
111+
bool IsC() const;
112+
bool IsObjC() const;
113+
bool IsCPlusPlus() const;
114+
uint16_t name = 0;
115+
uint32_t version = 0;
116+
};
117+
99118
struct OptionEnumValueElement {
100119
int64_t value;
101120
const char *string_value;

lldb/packages/Python/lldbsuite/test/builders/builder.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ def getLLDBSwiftLibs(self):
175175
return ["SWIFT_LIBS_DIR={}".format(configuration.swift_libs_dir)]
176176
return []
177177

178+
def getLLDBObjRoot(self):
179+
return ["LLDB_OBJ_ROOT={}".format(configuration.lldb_obj_root)]
180+
178181
def _getDebugInfoArgs(self, debug_info):
179182
if debug_info is None:
180183
return []
@@ -216,6 +219,7 @@ def getBuildCommand(
216219
self.getModuleCacheSpec(),
217220
self.getLibCxxArgs(),
218221
self.getLLDBSwiftLibs(),
222+
self.getLLDBObjRoot(),
219223
self.getCmdLine(dictionary),
220224
]
221225
command = list(itertools.chain(*command_parts))

lldb/packages/Python/lldbsuite/test/configuration.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127

128128
# LLDB library directory.
129129
lldb_libs_dir = None
130+
lldb_obj_root = None
130131

131132
libcxx_include_dir = None
132133
libcxx_include_target_dir = None

lldb/packages/Python/lldbsuite/test/dotest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ def parseOptionsAndInitTestdirs():
426426
configuration.lldb_module_cache_dir = os.path.join(
427427
configuration.test_build_dir, "module-cache-lldb"
428428
)
429+
429430
if args.clang_module_cache_dir:
430431
configuration.clang_module_cache_dir = args.clang_module_cache_dir
431432
else:
@@ -438,6 +439,8 @@ def parseOptionsAndInitTestdirs():
438439

439440
if args.lldb_libs_dir:
440441
configuration.lldb_libs_dir = args.lldb_libs_dir
442+
if args.lldb_obj_root:
443+
configuration.lldb_obj_root = args.lldb_obj_root
441444

442445
if args.enabled_plugins:
443446
configuration.enabled_plugins = args.enabled_plugins

lldb/packages/Python/lldbsuite/test/dotest_args.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,17 @@ def create_parser():
247247
metavar="The lib directory inside the Swift build directory",
248248
help="The lib directory inside the Swift build directory.",
249249
)
250+
group.add_argument(
251+
"--lldb-obj-root",
252+
dest="lldb_obj_root",
253+
metavar="path",
254+
help="The path to the LLDB object files.",
255+
)
250256
group.add_argument(
251257
"--lldb-libs-dir",
252258
dest="lldb_libs_dir",
253259
metavar="path",
254-
help="The path to LLDB library directory (containing liblldb)",
260+
help="The path to LLDB library directory (containing liblldb).",
255261
)
256262
group.add_argument(
257263
"--enable-plugin",

0 commit comments

Comments
 (0)