diff options
| author | Sean Callanan <scallanan@apple.com> | 2010-07-23 22:19:18 +0000 |
|---|---|---|
| committer | Sean Callanan <scallanan@apple.com> | 2010-07-23 22:19:18 +0000 |
| commit | 289e07b9d0de69cb956ebb12a57fd554b87adaa3 (patch) | |
| tree | f693940340b7e618373601608595618f07d77a84 /lldb/source | |
| parent | d65cd1d581d6bee9b62374df2b2be50b20e796d8 (diff) | |
| download | bcm5719-llvm-289e07b9d0de69cb956ebb12a57fd554b87adaa3.tar.gz bcm5719-llvm-289e07b9d0de69cb956ebb12a57fd554b87adaa3.zip | |
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.
llvm-svn: 109278
Diffstat (limited to 'lldb/source')
| -rw-r--r-- | lldb/source/Commands/CommandObjectExpression.cpp | 11 | ||||
| -rw-r--r-- | lldb/source/Expression/ClangExpression.cpp | 11 | ||||
| -rw-r--r-- | lldb/source/Expression/ClangExpressionDeclMap.cpp | 65 |
3 files changed, 82 insertions, 5 deletions
diff --git a/lldb/source/Commands/CommandObjectExpression.cpp b/lldb/source/Commands/CommandObjectExpression.cpp index 75cec780962..cd5c8f34efb 100644 --- a/lldb/source/Commands/CommandObjectExpression.cpp +++ b/lldb/source/Commands/CommandObjectExpression.cpp @@ -334,6 +334,17 @@ CommandObjectExpression::EvaluateExpression (const char *expr, bool bare, Stream { 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 = diff --git a/lldb/source/Expression/ClangExpression.cpp b/lldb/source/Expression/ClangExpression.cpp index cdb3383fd37..c3bdd7aecf5 100644 --- a/lldb/source/Expression/ClangExpression.cpp +++ b/lldb/source/Expression/ClangExpression.cpp @@ -669,10 +669,10 @@ ClangExpression::DisassembleFunction (Stream &stream, ExecutionContext &exe_ctx, 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 @@ ClangExpression::DisassembleFunction (Stream &stream, ExecutionContext &exe_ctx, DataExtractor extractor(buffer_sp, exe_ctx.process->GetByteOrder(), - 32); + exe_ctx.target->GetArchitecture().GetAddressByteSize()); if(log) { @@ -709,7 +709,7 @@ ClangExpression::DisassembleFunction (Stream &stream, ExecutionContext &exe_ctx, extractor.PutToLog (log, 0, extractor.GetByteSize(), - func_range.first, + func_remote_addr, 16, DataExtractor::TypeUInt8); } @@ -725,8 +725,9 @@ ClangExpression::DisassembleFunction (Stream &stream, ExecutionContext &exe_ctx, ++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, diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp index 1a9e57f0aa7..946ee67723a 100644 --- a/lldb/source/Expression/ClangExpressionDeclMap.cpp +++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp @@ -215,6 +215,71 @@ ClangExpressionDeclMap::Dematerialize (ExecutionContext *exe_ctx, 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, |

