[Lldb-commits] [PATCH] D26403: Display the pointer value in the libstdc++ unique_ptr summary

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 9 02:51:24 PST 2016

labath added inline comments.

Comment at: source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp:129
   if (m_ptr_obj->GetValueAsUnsigned(0) == 0) {
granata.enrico wrote:
> This is very nitpick-y but why not
> lldb::addr_t ptr_value = m_ptr_obj->GetValueAsUnsigned(LLDB_INVALID_ADDRESS)
> switch (ptr_value) {
>   case 0: stream.Printf("nullptr"); break;
>   case LLDB_INVALID_ADDRESS: return false;
>   default: stream.Printf("0x%" PRIx64, ptr_value); break;
> }
> modulo clang-formatting the above, of course.
I've changed this to:
  uint64_t ptr_value = m_ptr_obj->GetValueAsUnsigned(0, &success);
  if (!success)
    return false;
  if (ptr_value == 0)
    stream.Printf("0x%" PRIx64, ptr_value);
This should address the issue of not printing a bogus value if we fail to read the value, but avoid the case where the pointer value *is* 0xffff.. (which it can legitimately be, e.g. with custom deleters, or if the inferior corrupts it's memory).
At that point, the switch is not necessary.


More information about the lldb-commits mailing list