llvm-project/lldb/source/Expression
Jan Kratochvil df6879ec02 [lldb] Fix ARM32 inferior calls
echo -e '#include <unistd.h>\nint main(void){\nsync();return 0;}'|./bin/clang -g -x c -;./bin/lldb -o 'file ./a.out' -o 'b main' -o r -o 'p (void)sync()'

Actual:

  error: Expression can't be run, because there is no JIT compiled function

Expected:

  <nothing, sync() has been executed>

This patch has been checked by:
  D71707: clang-tidy: new bugprone-pointer-cast-widening
  https://reviews.llvm.org/D71707

Casting from 32-bit `void *` to `uint64_t` requires an intermediate `uintptr_t` cast otherwise the pointer gets sign-extended:

  echo -e '#include <stdio.h>\n#include <stdint.h>\nint main(void){void *p=(void *)0x80000000;unsigned long long ull=(unsigned long long)p;unsigned long long ull2=(unsigned long
long)(uintptr_t)p;printf("p=%p ull=0x%llx ull2=0x%llx\\n",p,ull,ull2);return 0;}'|gcc -Wall -m32 -x c -;./a.out
  <stdin>: In function ‘main’:
  <stdin>:3:66: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  p=0x80000000 ull=0xffffffff80000000 ull2=0x80000000

With debug output:
Actual:

  IRMemoryMap::WriteMemory (0xb6ff8640, 0xffffffffb6f82158, 0x112) went to [0xb6ff8640..0xb6ff86b3)
  Code can be run in the target.
  Found function, has local address 0xffffffffb6f84000 and remote address 0xffffffffffffffff
  Couldn't disassemble function : Couldn't find code range for function _Z12$__lldb_exprPv
  Sections:
  [0xb6f84000+0x3c]->0xb6ff9020 (alignment 4, section ID 0, name .text)
  ...
  HandleCommand, command did not succeed
  error: Expression can't be run, because there is no JIT compiled function

Expected:

  IRMemoryMap::WriteMemory (0xb6ff8640, 0xb6faa15c, 0x128) went to [0xb6ff8640..0xb6ff86c3)
  IRExecutionUnit::GetRemoteAddressForLocal() found 0xb6fac000 in [0xb6fac000..0xb6fac040], and returned 0xb6ff9020 from [0xb6ff9020..0xb6ff9060].
  Code can be run in the target.
  Found function, has local address 0xb6fac000 and remote address 0xb6ff9020
  Function's code range is [0xb6ff9020+0x40]
  ...
  Function data has contents:
  0xb6ff9020: 10 4c 2d e9 08 b0 8d e2 08 d0 4d e2 00 40 a0 e1
  ...
  Function disassembly:
  0xb6ff9020: 0xe92d4c10   push   {r4, r10, r11, lr}

Differential revision: https://reviews.llvm.org/D71498
2019-12-21 11:12:17 +01:00
..
CMakeLists.txt [Expression] Move IRDynamicChecks to ClangExpressionParser 2019-07-12 00:58:02 +00:00
DWARFExpression.cpp [lldb/DWARF] Switch to llvm location list parser 2019-12-09 13:39:10 +01:00
DiagnosticManager.cpp [lldb][NFC] Use unique_ptr in DiagnosticManager to express ownership 2019-10-10 08:30:10 +00:00
Expression.cpp [lldb][NFC] Move LLVM RTTI implementation from enum to static ID variable 2019-11-12 10:04:32 +01:00
ExpressionVariable.cpp Revert "[lldb] Move redundant persistent variable counter to ClangPersistentVariables" 2019-08-27 22:50:40 +00:00
FunctionCaller.cpp [lldb][NFC] Move LLVM RTTI implementation from enum to static ID variable 2019-11-12 10:04:32 +01:00
IRExecutionUnit.cpp [lldb] Fix ARM32 inferior calls 2019-12-21 11:12:17 +01:00
IRInterpreter.cpp [Logging] Replace Log::Printf with LLDB_LOG macro (NFC) 2019-07-24 17:56:10 +00:00
IRMemoryMap.cpp [lldb] Fix ARM32 inferior calls 2019-12-21 11:12:17 +01:00
LLVMUserExpression.cpp [lldb][NFC] Move LLVM RTTI implementation from enum to static ID variable 2019-11-12 10:04:32 +01:00
Materializer.cpp [CompilerType] Pass an ExecutionContextScope to GetTypeBitAlign. 2019-08-12 21:49:54 +00:00
REPL.cpp remove a smattering of isolated, unnecessary uses of FILE* 2019-10-09 21:50:52 +00:00
UserExpression.cpp [lldb][NFC] Move LLVM RTTI implementation from enum to static ID variable 2019-11-12 10:04:32 +01:00
UtilityFunction.cpp [lldb][NFC] Move LLVM RTTI implementation from enum to static ID variable 2019-11-12 10:04:32 +01:00