Skip to content

Commit 8a82d83

Browse files
Merge pull request llvm#8657 from adrian-prantl/126783312-6.0
Add a new SBExpressionOptions::SetLanguage() API
2 parents 5dc3fbd + f8a1db3 commit 8a82d83

File tree

60 files changed

+819
-185
lines changed

Some content is hidden

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

60 files changed

+819
-185
lines changed

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: 2 additions & 0 deletions
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)

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

@@ -196,7 +196,7 @@ class UserExpression : public Expression {
196196
virtual bool IsParseCacheable() { return true; }
197197
/// Return the language that should be used when parsing. To use the
198198
/// default, return eLanguageTypeUnknown.
199-
lldb::LanguageType Language() const override { return m_language; }
199+
SourceLanguage Language() const override { return m_language; }
200200

201201
/// Return the desired result type of the function, or eResultTypeAny if
202202
/// indifferent.
@@ -308,19 +308,22 @@ class UserExpression : public Expression {
308308
lldb::ProcessSP &process_sp,
309309
lldb::StackFrameSP &frame_sp);
310310

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

326329
} // namespace lldb_private

lldb/include/lldb/Symbol/TypeSystem.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,10 @@ class TypeSystem : public PluginInterface,
515515
return IsPointerOrReferenceType(type, nullptr);
516516
}
517517

518-
virtual UserExpression *
519-
GetUserExpression(llvm::StringRef expr, llvm::StringRef prefix,
520-
lldb::LanguageType language,
521-
Expression::ResultType desired_type,
522-
const EvaluateExpressionOptions &options,
523-
ValueObject *ctx_obj) {
518+
virtual UserExpression *GetUserExpression(
519+
llvm::StringRef expr, llvm::StringRef prefix, SourceLanguage language,
520+
Expression::ResultType desired_type,
521+
const EvaluateExpressionOptions &options, ValueObject *ctx_obj) {
524522
return nullptr;
525523
}
526524

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: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class TargetProperties : public Properties {
241241

242242
bool GetBreakpointsConsultPlatformAvoidList();
243243

244-
lldb::LanguageType GetLanguage() const;
244+
SourceLanguage GetLanguage() const;
245245

246246
llvm::StringRef GetExpressionPrefixContents();
247247

@@ -355,9 +355,18 @@ class EvaluateExpressionOptions {
355355
m_execution_policy = policy;
356356
}
357357

358-
lldb::LanguageType GetLanguage() const { return m_language; }
358+
SourceLanguage GetLanguage() const { return m_language; }
359359

360-
void SetLanguage(lldb::LanguageType language) { m_language = language; }
360+
void SetLanguage(lldb::LanguageType language_type) {
361+
m_language = SourceLanguage(language_type);
362+
}
363+
364+
/// Set the language using a pair of language code and version as
365+
/// defined by the DWARF 6 specification.
366+
/// WARNING: These codes may change until DWARF 6 is finalized.
367+
void SetLanguage(uint16_t name, uint32_t version) {
368+
m_language = SourceLanguage(name, version);
369+
}
361370

362371
bool DoesCoerceToId() const { return m_coerce_to_id; }
363372

@@ -520,7 +529,7 @@ class EvaluateExpressionOptions {
520529

521530
private:
522531
ExecutionPolicy m_execution_policy = default_execution_policy;
523-
lldb::LanguageType m_language = lldb::eLanguageTypeUnknown;
532+
SourceLanguage m_language;
524533
std::string m_prefix;
525534
bool m_coerce_to_id = false;
526535
bool m_unwind_on_error = true;
@@ -1248,7 +1257,7 @@ class Target : public std::enable_shared_from_this<Target>,
12481257

12491258
UserExpression *
12501259
GetUserExpressionForLanguage(llvm::StringRef expr, llvm::StringRef prefix,
1251-
lldb::LanguageType language,
1260+
SourceLanguage language,
12521261
Expression::ResultType desired_type,
12531262
const EvaluateExpressionOptions &options,
12541263
ValueObject *ctx_obj, Status &error);

0 commit comments

Comments
 (0)