[Lldb-commits] [PATCH] D71514: Minor fixes of signed pointers for 32-bit hosts on top of D71498

Jan Kratochvil via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Dec 14 08:21:32 PST 2019


jankratochvil created this revision.
jankratochvil added reviewers: omjavaid, labath, jasonmolenda.
jankratochvil added a project: LLDB.
Herald added a subscriber: emaste.
jankratochvil added a parent revision: D71498: Fix ARM32 inferior calls.

This is a similar fix as D71498 <https://reviews.llvm.org/D71498> just for code with less visible impact.
I haven't tried to execute this code, I have no testcase for it.

I have made a full class wrapper of `addr_t` <https://people.redhat.com/jkratoch/addr_t2.patch>, not sure if you think it makes sense to upstream it (after cleaning it up a bit). It disclosed these issues:

- `GetCrashReasonString`
  - FIX here: `reinterpret_cast<lldb::addr_t>`
- `NativeProcessLinux::ReadMemory`
  - safe: `reinterpret_cast<void *>`
  - safe: `(void *)addr`
- `NativeProcessLinux::WriteMemory`
  - safe: `(void *)addr`
- `Value::GetValueAsData`
  - safe: `reinterpret_cast<uint8_t *>(address)`
- `ValueObject::GetPointeeData`
  - safe: `(uint8_t *)(addr + offset)`
- `Type::ReadFromMemory`
  - safe: `reinterpret_cast<uint8_t *>(addr)`
- `IRMemoryMap::Malloc`
  - FIX here: `(uint64_t)(lldb::addr_t)process_sp.get()`
- `IRExecutionUnit::GetRunnableInfo`
  - FIX by D71498 <https://reviews.llvm.org/D71498>: `(lldb::addr_t)fun_ptr`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71514

Files:
  lldb/source/Expression/IRMemoryMap.cpp
  lldb/source/Plugins/Process/POSIX/CrashReason.cpp


Index: lldb/source/Plugins/Process/POSIX/CrashReason.cpp
===================================================================
--- lldb/source/Plugins/Process/POSIX/CrashReason.cpp
+++ lldb/source/Plugins/Process/POSIX/CrashReason.cpp
@@ -136,15 +136,14 @@
 #if defined(si_lower) && defined(si_upper)
   if (reason == CrashReason::eBoundViolation) {
     str = "signal SIGSEGV";
-    AppendBounds(str, reinterpret_cast<lldb::addr_t>(info.si_lower),
-                 reinterpret_cast<lldb::addr_t>(info.si_upper),
-                 reinterpret_cast<lldb::addr_t>(info.si_addr));
+    AppendBounds(str, (lldb::addr_t)(uintptr_t)info.si_lower,
+                 (lldb::addr_t)(uintptr_t)info.si_upper,
+                 (lldb::addr_t)(uintptr_t)info.si_addr);
     return str;
   }
 #endif
 
-  return GetCrashReasonString(reason,
-                              reinterpret_cast<lldb::addr_t>(info.si_addr));
+  return GetCrashReasonString(reason, (lldb::addr_t)(uintptr_t)info.si_addr);
 }
 
 std::string GetCrashReasonString(CrashReason reason, lldb::addr_t fault_addr) {
Index: lldb/source/Expression/IRMemoryMap.cpp
===================================================================
--- lldb/source/Expression/IRMemoryMap.cpp
+++ lldb/source/Expression/IRMemoryMap.cpp
@@ -330,7 +330,7 @@
     LLDB_LOGF(log,
               "IRMemoryMap::%s process_sp=0x%" PRIx64
               ", process_sp->CanJIT()=%s, process_sp->IsAlive()=%s",
-              __FUNCTION__, (lldb::addr_t)process_sp.get(),
+              __FUNCTION__, (uint64_t)(uintptr_t)process_sp.get(),
               process_sp && process_sp->CanJIT() ? "true" : "false",
               process_sp && process_sp->IsAlive() ? "true" : "false");
     if (process_sp && process_sp->CanJIT() && process_sp->IsAlive()) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71514.233936.patch
Type: text/x-patch
Size: 1778 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20191214/de9f5cd7/attachment-0001.bin>


More information about the lldb-commits mailing list