[Lldb-commits] [PATCH] D136620: Change how debugserver clears auth bits from pc/fp/sp/lr with thread_get_state on Darwin

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 24 10:28:36 PDT 2022


JDevlieghere added inline comments.


================
Comment at: lldb/tools/debugserver/source/DNB.cpp:1830-1837
+  static bool g_tried_addressing_bits_syscall = false;
+  if (g_tried_addressing_bits_syscall == false) {
+    size_t len = sizeof(uint32_t);
+    if (::sysctlbyname("machdep.virtual_address_size", &g_addressing_bits, &len,
+                       NULL, 0) != 0) {
+      g_addressing_bits = 0;
+    }
----------------
A more C++ and thread safe way of doing this is:

```
static std::once_flag g_once_flag;
std::call_once(g_once_flag, [&](){
	size_t len = sizeof(uint32_t);
	if (::sysctlbyname("machdep.virtual_address_size", &g_addressing_bits, &len,
	                   NULL, 0) != 0) {
	  g_addressing_bits = 0;
	}
}
```


================
Comment at: lldb/tools/debugserver/source/DNB.cpp:1840-1843
+  if (addressing_bits > 0)
+    return true;
+  else
+    return false;
----------------
```return g_addressing_bits > 0```


================
Comment at: lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp:98-100
+  uint32_t addressing_bits = 0;
+  if (!DNBGetAddressingBits(addressing_bits) || addressing_bits == 0)
+    return value;
----------------
Doesn't `DNBGetAddressingBits` already cover the case of `addressing_bits` being `0`? Why not have `DNBGetAddressingBits` return the addressing bits and do the check here?  


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136620/new/

https://reviews.llvm.org/D136620



More information about the lldb-commits mailing list