[Lldb-commits] [lldb] r109278 - in /lldb/trunk: include/lldb/Expression/ClangExpressionDeclMap.h source/Commands/CommandObjectExpression.cpp source/Expression/ClangExpression.cpp source/Expression/ClangExpressionDeclMap.cpp

Sean Callanan scallanan at apple.com
Fri Jul 23 15:19:18 PDT 2010


Author: spyffe
Date: Fri Jul 23 17:19:18 2010
New Revision: 109278

URL: http://llvm.org/viewvc/llvm-project?rev=109278&view=rev
Log:
Added logging:
- When we JIT an expression, we print the disassembly
  of the generated code
- When we put the structure into the target, we print
  the individual entries in the structure byte for
  byte.

Modified:
    lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
    lldb/trunk/source/Commands/CommandObjectExpression.cpp
    lldb/trunk/source/Expression/ClangExpression.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp

Modified: lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h?rev=109278&r1=109277&r2=109278&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h (original)
+++ lldb/trunk/include/lldb/Expression/ClangExpressionDeclMap.h Fri Jul 23 17:19:18 2010
@@ -96,6 +96,10 @@
                      lldb::addr_t &struct_address,
                      Error &error);
     
+    bool DumpMaterializedStruct(ExecutionContext *exe_ctx,
+                                Stream &s,
+                                Error &error);
+    
     bool Dematerialize(ExecutionContext *exe_ctx,
                        lldb_private::Value &result_value,
                        Error &error);
@@ -155,7 +159,6 @@
     void AddOneVariable(NameSearchContext &context, Variable *var);
     void AddOneFunction(NameSearchContext &context, Function *fun);
     
-    // Set D to dematerialize instead
     bool DoMaterialize (bool dematerialize,
                         ExecutionContext *exe_ctx,
                         lldb_private::Value *result_value, /* must be non-NULL if D is set */

Modified: lldb/trunk/source/Commands/CommandObjectExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectExpression.cpp?rev=109278&r1=109277&r2=109278&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectExpression.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectExpression.cpp Fri Jul 23 17:19:18 2010
@@ -334,6 +334,17 @@
                 {
                     log->Printf("Function disassembly:\n%s", insns.GetData());
                 }
+                
+                StreamString args;
+                
+                if (!expr_decl_map.DumpMaterializedStruct(&m_exe_ctx, args, err))
+                {
+                    log->Printf("Couldn't extract variable values : %s", err.AsCString("unknown error"));
+                }
+                else
+                {
+                    log->Printf("Structure contents:\n%s", args.GetData());
+                }
             }
                         
             ClangFunction::ExecutionResults execution_result = 

Modified: lldb/trunk/source/Expression/ClangExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpression.cpp?rev=109278&r1=109277&r2=109278&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpression.cpp Fri Jul 23 17:19:18 2010
@@ -669,10 +669,10 @@
         ret.SetErrorString("Couldn't find the target");
     }
     
-    lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second - func_range.first, 0));
+    lldb::DataBufferSP buffer_sp(new DataBufferHeap(func_range.second - func_remote_addr, 0));
         
     Error err;
-    exe_ctx.process->ReadMemory(func_range.first, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err);
+    exe_ctx.process->ReadMemory(func_remote_addr, buffer_sp->GetBytes(), buffer_sp->GetByteSize(), err);
     
     if (!err.Success())
     {
@@ -701,7 +701,7 @@
     
     DataExtractor extractor(buffer_sp, 
                             exe_ctx.process->GetByteOrder(),
-                            32);
+                            exe_ctx.target->GetArchitecture().GetAddressByteSize());
     
     if(log)
     {
@@ -709,7 +709,7 @@
         extractor.PutToLog (log,
                             0,
                             extractor.GetByteSize(),
-                            func_range.first,
+                            func_remote_addr,
                             16,
                             DataExtractor::TypeUInt8);
     }
@@ -725,8 +725,9 @@
          ++instruction_index)
     {
         Disassembler::Instruction *instruction = instruction_list.GetInstructionAtIndex(instruction_index);
+        Address addr(NULL, func_remote_addr + bytes_offset);
         instruction->Dump (&stream,
-                           NULL,
+                           &addr,
                            &extractor, 
                            bytes_offset, 
                            exe_ctx, 

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=109278&r1=109277&r2=109278&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Fri Jul 23 17:19:18 2010
@@ -215,6 +215,71 @@
     return DoMaterialize(true, exe_ctx, &result_value, err);
 }
 
+bool
+ClangExpressionDeclMap::DumpMaterializedStruct(ExecutionContext *exe_ctx, 
+                                               Stream &s,
+                                               Error &err)
+{
+    if (!m_struct_laid_out)
+    {
+        err.SetErrorString("Structure hasn't been laid out yet");
+        return false;
+    }
+    
+    if (!exe_ctx)
+    {
+        err.SetErrorString("Received null execution context");
+        return false;
+    }
+    
+    
+    if (!exe_ctx->process)
+    {
+        err.SetErrorString("Couldn't find the process");
+        return false;
+    }
+    
+    if (!exe_ctx->target)
+    {
+        err.SetErrorString("Couldn't find the target");
+        return false;
+    }
+    
+    lldb::DataBufferSP data(new DataBufferHeap(m_struct_size, 0));    
+    
+    Error error;
+    if (exe_ctx->process->ReadMemory (m_materialized_location, data->GetBytes(), data->GetByteSize(), error) != data->GetByteSize())
+    {
+        err.SetErrorStringWithFormat ("Couldn't read struct from the target: %s", error.AsCString());
+        return false;
+    }
+    
+    DataExtractor extractor(data, exe_ctx->process->GetByteOrder(), exe_ctx->target->GetArchitecture().GetAddressByteSize());
+    
+    StructMemberIterator iter;
+    
+    for (iter = m_members.begin();
+         iter != m_members.end();
+         ++iter)
+    {
+        s.Printf("[%s]\n", iter->m_name.c_str());
+        
+        extractor.Dump(&s,                                          // stream
+                       iter->m_offset,                              // offset
+                       lldb::eFormatBytesWithASCII,                 // format
+                       1,                                           // byte size of individual entries
+                       iter->m_size,                                // number of entries
+                       16,                                          // entries per line
+                       m_materialized_location + iter->m_offset,    // address to print
+                       0,                                           // bit size (bitfields only; 0 means ignore)
+                       0);                                          // bit alignment (bitfields only; 0 means ignore)
+        
+        s.PutChar('\n');
+    }
+    
+    return true;
+}
+
 bool 
 ClangExpressionDeclMap::DoMaterialize (bool dematerialize,
                                        ExecutionContext *exe_ctx,





More information about the lldb-commits mailing list