Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
690cfee
Add an API call to DIL from SBFrame
kuilpd Dec 19, 2024
fcaffbc
Add unittests from lldb-eval
kuilpd Dec 19, 2024
fe7d5ee
Add a fuzzer
kuilpd Dec 12, 2024
7cdd908
Get fuzzer test binary via a relative path
kuilpd Dec 16, 2024
ce481f5
Change 'aka' to 'canonically referred to' in error messages
kuilpd Dec 20, 2024
5776ef9
Add more cases for floating numbers
kuilpd Jan 13, 2025
aabfc5e
Remove fuzzer (will move to another branch)
kuilpd Jan 23, 2025
6011c6d
Apply git-clang-format
kuilpd Jan 23, 2025
98e599e
Adjust division by zero tests to check the error message
kuilpd Jan 23, 2025
64f8a63
Add XFail matcher with a counter & mark failed tests XFail
kuilpd Jan 24, 2025
d7dd93e
Disable tests suites with registers, chars, strings
kuilpd Jan 24, 2025
44b49f0
Skip crashing nullptr tests & restore working nullptr tests
kuilpd Jan 24, 2025
a84236c
Create placeholders for scope, context, parsing evaluation & disable …
kuilpd Jan 24, 2025
25b91d5
Restore TestStaticConstDeclaredInline
kuilpd Jan 24, 2025
75a7312
Fix compiler warnings
kuilpd Jan 24, 2025
e106f54
DIL TODO comment
kuilpd Jan 24, 2025
d650dc2
Remove libstdc++ test binary
kuilpd Jan 24, 2025
5a5df30
Compile the test binary with the in-tree clang and lld
kuilpd Jan 27, 2025
a603934
Add the full path to test_binary.cc
kuilpd Jan 28, 2025
42704d8
Link test_binary against in-tree libc++
kuilpd Jan 29, 2025
09c8fc3
Make unique_ptr tests work with current libc++
kuilpd Jan 29, 2025
58861ca
Rename files
kuilpd Feb 5, 2025
a404e7c
Skip 3 tests with error string mismatch
kuilpd Feb 5, 2025
56780ef
Move GTEST_SKIP() to the end of test fixtures
kuilpd Feb 6, 2025
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
3 changes: 3 additions & 0 deletions lldb/include/lldb/API/SBFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ class LLDB_API SBFrame {
lldb::SBValue EvaluateExpression(const char *expr,
const SBExpressionOptions &options);

lldb::SBValue EvaluateExpressionViaDIL(const char *expr,
lldb::DynamicValueType use_dynamic);

/// Language plugins can use this API to report language-specific
/// runtime information about this compile unit, such as additional
/// language version details or feature flags.
Expand Down
76 changes: 76 additions & 0 deletions lldb/source/API/SBFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,82 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr,
return expr_result;
}

lldb::SBValue
SBFrame::EvaluateExpressionViaDIL(const char *expr,
lldb::DynamicValueType use_dynamic) {
LLDB_INSTRUMENT_VA(this, expr);
Log *expr_log = GetLog(LLDBLog::Expressions);
SBValue expr_result;
if (expr == nullptr || expr[0] == '\0') {
return expr_result;
}
ValueObjectSP expr_value_sp;
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
StackFrame *frame = nullptr;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
SBExpressionOptions options;
options.SetFetchDynamicValue(use_dynamic);
if (target && process) {
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock())) {
frame = exe_ctx.GetFramePtr();
if (frame) {
std::unique_ptr<llvm::PrettyStackTraceFormat> stack_trace;
if (target->GetDisplayExpressionsInCrashlogs()) {
StreamString frame_description;
frame->DumpUsingSettingsFormat(&frame_description);
stack_trace = std::make_unique<llvm::PrettyStackTraceFormat>(
"SBFrame::EvaluateExpressionViaDIL (expr = \"%s\", "
"fetch_dynamic_value "
"= %u) %s",
expr, options.GetFetchDynamicValue(),
frame_description.GetData());
}
VariableSP var_sp;
Status error;
expr_value_sp =
frame->GetValueForVariableExpressionPath( // DIL in ths branch
expr, use_dynamic,
StackFrame::eExpressionPathOptionCheckPtrVsMember |
StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
var_sp, error);
if (!error.Success()) {
expr_value_sp =
ValueObjectConstResult::Create(nullptr, std::move(error));
expr_result.SetSP(expr_value_sp, false);
} else {
expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
}
}
} else {
Status error;
error = Status::FromErrorString("can't evaluate expressions when the "
"process is running.");
expr_value_sp = ValueObjectConstResult::Create(nullptr, std::move(error));
expr_result.SetSP(expr_value_sp, false);
}
} else {
Status error;
error = Status::FromErrorString("sbframe object is not valid.");
expr_value_sp = ValueObjectConstResult::Create(nullptr, std::move(error));
expr_result.SetSP(expr_value_sp, false);
}
if (expr_result.GetError().Success())
LLDB_LOGF(expr_log,
"** [SBFrame::EvaluateExpressionViaDIL] Expression result is "
"%s, summary %s **",
expr_result.GetValue(), expr_result.GetSummary());
else
LLDB_LOGF(
expr_log,
"** [SBFrame::EvaluateExpressionViaDIL] Expression evaluation failed: "
"%s **",
expr_result.GetError().GetCString());
return expr_result;
}

SBStructuredData SBFrame::GetLanguageSpecificData() const {
LLDB_INSTRUMENT_VA(this);

Expand Down
1 change: 1 addition & 0 deletions lldb/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ add_subdirectory(Breakpoint)
add_subdirectory(Callback)
add_subdirectory(Core)
add_subdirectory(DataFormatter)
add_subdirectory(DIL)
add_subdirectory(Disassembler)
add_subdirectory(Editline)
add_subdirectory(Expression)
Expand Down
13 changes: 13 additions & 0 deletions lldb/unittests/DIL/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
add_lldb_unittest(DILTests
DILTests.cpp
Runner.cpp

LINK_LIBS
liblldb
lldbUtilityHelpers
LLVMTestingSupport
)
add_subdirectory(Inputs)
add_dependencies(DILTests test_binary)

add_unittest_inputs(DILTests "test_binary.cc")
Loading