[Lldb-commits] [lldb] r157484 - in /lldb/trunk: include/lldb/Core/Disassembler.h source/Commands/CommandObjectMemory.cpp source/Core/Disassembler.cpp source/Target/Target.cpp

Greg Clayton gclayton at apple.com
Fri May 25 10:05:55 PDT 2012


Author: gclayton
Date: Fri May 25 12:05:55 2012
New Revision: 157484

URL: http://llvm.org/viewvc/llvm-project?rev=157484&view=rev
Log:
<rdar://problem/11534686> 

Reading memory from a file when the section is encrypted doesn't show an error. No we do.


Modified:
    lldb/trunk/include/lldb/Core/Disassembler.h
    lldb/trunk/source/Commands/CommandObjectMemory.cpp
    lldb/trunk/source/Core/Disassembler.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/Core/Disassembler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Disassembler.h?rev=157484&r1=157483&r2=157484&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Disassembler.h (original)
+++ lldb/trunk/include/lldb/Core/Disassembler.h Fri May 25 12:05:55 2012
@@ -338,7 +338,8 @@
     
     size_t
     ParseInstructions (const ExecutionContext *exe_ctx,
-                       const AddressRange &range);
+                       const AddressRange &range,
+                       Stream *error_strm_ptr);
 
     size_t
     ParseInstructions (const ExecutionContext *exe_ctx,

Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=157484&r1=157483&r2=157484&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Fri May 25 12:05:55 2012
@@ -613,8 +613,15 @@
             bytes_read = target->ReadMemory(address, false, data_sp->GetBytes (), data_sp->GetByteSize(), error);
             if (bytes_read == 0)
             {
-                result.AppendWarningWithFormat("Read from 0x%llx failed.\n", addr);
-                result.AppendError(error.AsCString());
+                const char *error_cstr = error.AsCString();
+                if (error_cstr && error_cstr[0])
+                {
+                    result.AppendError(error_cstr);
+                }
+                else
+                {
+                    result.AppendErrorWithFormat("failed to read memory from 0x%llx.\n", addr);
+                }
                 result.SetStatus(eReturnStatusFailed);
                 return false;
             }

Modified: lldb/trunk/source/Core/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=157484&r1=157483&r2=157484&view=diff
==============================================================================
--- lldb/trunk/source/Core/Disassembler.cpp (original)
+++ lldb/trunk/source/Core/Disassembler.cpp Fri May 25 12:05:55 2012
@@ -225,7 +225,7 @@
 
         if (disasm_sp)
         {
-            size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range);
+            size_t bytes_disassembled = disasm_sp->ParseInstructions (&exe_ctx, range, NULL);
             if (bytes_disassembled == 0)
                 disasm_sp.reset();
         }
@@ -290,7 +290,7 @@
             ResolveAddress (exe_ctx, disasm_range.GetBaseAddress(), range.GetBaseAddress());
             range.SetByteSize (disasm_range.GetByteSize());
             
-            size_t bytes_disassembled = disasm_ap->ParseInstructions (&exe_ctx, range);
+            size_t bytes_disassembled = disasm_ap->ParseInstructions (&exe_ctx, range, &strm);
             if (bytes_disassembled == 0)
                 return false;
 
@@ -1010,7 +1010,8 @@
 Disassembler::ParseInstructions
 (
     const ExecutionContext *exe_ctx,
-    const AddressRange &range
+    const AddressRange &range,
+    Stream *error_strm_ptr
 )
 {
     if (exe_ctx)
@@ -1040,6 +1041,18 @@
                                 m_arch.GetAddressByteSize());
             return DecodeInstructions (range.GetBaseAddress(), data, 0, UINT32_MAX, false);
         }
+        else if (error_strm_ptr)
+        {
+            const char *error_cstr = error.AsCString();
+            if (error_cstr)
+            {
+                error_strm_ptr->Printf("error: %s\n", error_cstr);
+            }
+        }
+    }
+    else if (error_strm_ptr)
+    {
+        error_strm_ptr->PutCString("error: invalid execution context\n");
     }
     return 0;
 }

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=157484&r1=157483&r2=157484&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri May 25 12:05:55 2012
@@ -1062,6 +1062,7 @@
         // If the contents of this section are encrypted, the on-disk file is unusuable.  Read only from live memory.
         if (section_sp->IsEncrypted())
         {
+            error.SetErrorString("section is encrypted");
             return 0;
         }
         ModuleSP module_sp (section_sp->GetModule());





More information about the lldb-commits mailing list