llvm-project/lldb/test/Shell
Vedant Kumar 14135f50a0 [lldb/Value] Avoid reading more data than the host has available
Value::GetValueByteSize() reports the size of a Value as the size of its
underlying CompilerType. However, a host buffer that backs a Value may
be smaller than GetValueByteSize().

This situation arises when the host is only able to partially evaluate a
Value, e.g. because the expression contains DW_OP_piece.

The cleanest fix I've found to this problem is Greg's suggestion, which
is to resize the Value if (after evaluating an expression) it's found to
be too small. I've tried several alternatives which all (in one way or
the other) tried to teach the Value/ValueObjectChild system not to read
past the end of a host buffer, but this was flaky and impractical as it
isn't easy to figure out the host buffer's size (Value::GetScalar() can
point to somewhere /inside/ a host buffer, but you need to walk up the
ValueObject hierarchy to try and find its size).

This fixes an ASan error in lldb seen when debugging a clang binary.
I've added a regression test in test/functionalities/optimized_code. The
point of that test is not specifically to check that DW_OP_piece is
handled a particular way, but rather to check that lldb doesn't crash on
an input that it used to crash on.

Testing: check-lldb, and running the added tests using a sanitized lldb

--

Thanks to Jim for pointing out that an earlier version of this patch,
which simply changed the definition of Value::GetValueByteSize(), would
interact poorly with the ValueObject machinery.

Thanks also to Pavel who suggested a neat way to test this change
(which, incidentally, caught another ASan issue still present in the
original version of this patch).

rdar://58665925

Differential Revision: https://reviews.llvm.org/D73148
2020-01-31 16:33:12 -08:00
..
Breakpoint BreakpointDummyOptionGroup was using g_breakpoint_modify_options rather than g_breakpoint_dummy_options 2019-11-07 14:25:04 -08:00
BuildScript Re-land "[test] Split LLDB tests into API, Shell & Unit" 2019-10-09 19:22:02 +00:00
Commands [lldb/Commands] Make column available through _regexp-break 2020-01-27 15:11:00 -08:00
Driver [lldb/Reproducer] Mark some driver tests as unsupported for lldb-repro 2020-01-22 17:18:06 -08:00
ExecControl/StopHook [lldb/lit] Introduce %clang_host substitutions 2019-10-31 10:40:37 +01:00
Expr [lldb/lit] Introduce %clang_host substitutions 2019-10-31 10:40:37 +01:00
Heap [lldb/lit] Introduce %clang_host substitutions 2019-10-31 10:40:37 +01:00
Host [lldb/lit] Introduce %clang_host substitutions 2019-10-31 10:40:37 +01:00
Minidump [lldb] Allow loading of minidumps with no process id 2020-01-20 13:08:58 +01:00
ObjectFile [AVR] Recognize the AVR architecture in lldb 2020-01-30 13:40:31 +01:00
Process [lldb/Test] Use lit's capabilities to skip lldb-repro tests. 2020-01-22 13:24:12 -08:00
Quit [lldb/Test] Use lit's capabilities to skip lldb-repro tests. 2020-01-22 13:24:12 -08:00
Register [lldb] [test] Restrict x86-64-write register test to x86-64 2020-01-28 22:15:23 +01:00
Reproducer [lldb/Test] Use lit's capabilities to skip lldb-repro tests. 2020-01-22 13:24:12 -08:00
ScriptInterpreter [lldb/Test] Use lit.local.cfg to mark whole directory as (un)supported. 2020-01-27 15:11:00 -08:00
Settings [FormatEntity] Add mangled function name support 2019-12-12 10:22:57 -08:00
SymbolFile [lldb/Value] Avoid reading more data than the host has available 2020-01-31 16:33:12 -08:00
Unwind [lldb] Fix eh-frame-small-fde test for changes in lld 2020-01-13 11:17:34 +01:00
Watchpoint [lldb] [Process/NetBSD] Copy watchpoints to newly-created threads 2019-11-25 20:11:59 +01:00
helper [lldb/Test] Disallow using substituted binaries in shell test. 2020-01-23 14:39:27 -08:00
.clang-format [test] Add a .clang-format file for the shell test. 2019-10-17 21:23:35 +00:00
CMakeLists.txt [lldb/Reproducers] Fix typo in CMake so we actually replay. 2020-01-30 15:51:29 -08:00
lit-lldb-init.in Re-land "[test] Split LLDB tests into API, Shell & Unit" 2019-10-09 19:22:02 +00:00
lit.cfg.py [lldb/Test] Use lit's capabilities to skip lldb-repro tests. 2020-01-22 13:24:12 -08:00
lit.site.cfg.py.in [lldb/Lua] Implement a Simple Lua Script Interpreter Prototype 2019-12-20 11:19:47 -08:00