[Lldb-commits] [lldb] r299609 - getAsInteger is not a equivalent replacement for strtol

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 5 18:33:38 PDT 2017


Author: jingham
Date: Wed Apr  5 20:33:38 2017
New Revision: 299609

URL: http://llvm.org/viewvc/llvm-project?rev=299609&view=rev
Log:
getAsInteger is not a equivalent replacement for strtol

work around that fact for CommandObjectMemoryWrite.

<rdar://problem/31457148>

Modified:
    lldb/trunk/source/Commands/CommandObjectMemory.cpp

Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=299609&r1=299608&r2=299609&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Wed Apr  5 20:33:38 2017
@@ -1443,8 +1443,16 @@ protected:
       case eFormatHex:
       case eFormatHexUppercase:
       case eFormatPointer:
+      {
         // Decode hex bytes
-        if (entry.ref.getAsInteger(16, uval64)) {
+        // Be careful, getAsInteger with a radix of 16 rejects "0xab" so we
+        // have to special case that:
+        bool success = false;
+        if (entry.ref.startswith("0x"))
+          success = !entry.ref.getAsInteger(0, uval64);
+        if (!success)
+          success = !entry.ref.getAsInteger(16, uval64);
+        if (!success) {
           result.AppendErrorWithFormat(
               "'%s' is not a valid hex string value.\n", entry.c_str());
           result.SetStatus(eReturnStatusFailed);
@@ -1459,7 +1467,7 @@ protected:
         }
         buffer.PutMaxHex64(uval64, item_byte_size);
         break;
-
+      }
       case eFormatBoolean:
         uval64 = Args::StringToBoolean(entry.ref, false, &success);
         if (!success) {




More information about the lldb-commits mailing list