[Lldb-commits] [lldb] r156549 - in /lldb/branches/apple/python-GIL: ./ include/lldb/Core/ include/lldb/Target/ lldb.xcodeproj/ lldb.xcodeproj/xcshareddata/xcschemes/ source/API/ source/Core/ source/Expression/ source/Plugins/Disassembler/llvm/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/UnwindAssembly/InstEmulation/ source/Symbol/ source/Target/ test/ test/lang/objc/objc-stepping/ tools/driver/
Filipe Cabecinhas
me at filcab.net
Thu May 10 09:19:22 PDT 2012
Author: filcab
Date: Thu May 10 11:19:22 2012
New Revision: 156549
URL: http://llvm.org/viewvc/llvm-project?rev=156549&view=rev
Log:
Merged /lldb/trunk:r156505-156548
Modified:
lldb/branches/apple/python-GIL/ (props changed)
lldb/branches/apple/python-GIL/include/lldb/Core/Disassembler.h
lldb/branches/apple/python-GIL/include/lldb/Core/Opcode.h
lldb/branches/apple/python-GIL/include/lldb/Core/StreamString.h
lldb/branches/apple/python-GIL/include/lldb/Target/Thread.h
lldb/branches/apple/python-GIL/include/lldb/Target/ThreadPlanCallFunction.h
lldb/branches/apple/python-GIL/include/lldb/Target/ThreadPlanStepThrough.h
lldb/branches/apple/python-GIL/lldb.xcodeproj/project.pbxproj
lldb/branches/apple/python-GIL/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
lldb/branches/apple/python-GIL/source/API/SBInstruction.cpp
lldb/branches/apple/python-GIL/source/API/SBInstructionList.cpp
lldb/branches/apple/python-GIL/source/Core/Disassembler.cpp
lldb/branches/apple/python-GIL/source/Core/Opcode.cpp
lldb/branches/apple/python-GIL/source/Core/StreamString.cpp
lldb/branches/apple/python-GIL/source/Expression/ClangExpressionParser.cpp
lldb/branches/apple/python-GIL/source/Expression/ExpressionSourceCode.cpp
lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h
lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
lldb/branches/apple/python-GIL/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
lldb/branches/apple/python-GIL/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
lldb/branches/apple/python-GIL/source/Symbol/SymbolContext.cpp
lldb/branches/apple/python-GIL/source/Target/Thread.cpp
lldb/branches/apple/python-GIL/source/Target/ThreadPlan.cpp
lldb/branches/apple/python-GIL/source/Target/ThreadPlanCallFunction.cpp
lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepInRange.cpp
lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepOverRange.cpp
lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepThrough.cpp
lldb/branches/apple/python-GIL/source/Target/ThreadPlanTracer.cpp
lldb/branches/apple/python-GIL/test/lang/objc/objc-stepping/TestObjCStepping.py
lldb/branches/apple/python-GIL/test/lang/objc/objc-stepping/stepping-tests.m
lldb/branches/apple/python-GIL/test/redo.py
lldb/branches/apple/python-GIL/tools/driver/Driver.cpp
lldb/branches/apple/python-GIL/tools/driver/IOChannel.cpp
lldb/branches/apple/python-GIL/tools/driver/IOChannel.h
Propchange: lldb/branches/apple/python-GIL/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu May 10 11:19:22 2012
@@ -1 +1 @@
-/lldb/trunk:156469-156504
+/lldb/trunk:156467-156548
Modified: lldb/branches/apple/python-GIL/include/lldb/Core/Disassembler.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Core/Disassembler.h?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Core/Disassembler.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Core/Disassembler.h Thu May 10 11:19:22 2012
@@ -42,27 +42,27 @@
}
const char *
- GetMnemonic (ExecutionContextScope *exe_scope)
+ GetMnemonic (const ExecutionContext* exe_ctx)
{
- CalculateMnemonicOperandsAndCommentIfNeeded (exe_scope);
+ CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
return m_opcode_name.c_str();
}
const char *
- GetOperands (ExecutionContextScope *exe_scope)
+ GetOperands (const ExecutionContext* exe_ctx)
{
- CalculateMnemonicOperandsAndCommentIfNeeded (exe_scope);
+ CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
return m_mnemocics.c_str();
}
const char *
- GetComment (ExecutionContextScope *exe_scope)
+ GetComment (const ExecutionContext* exe_ctx)
{
- CalculateMnemonicOperandsAndCommentIfNeeded (exe_scope);
+ CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
return m_comment.c_str();
}
virtual void
- CalculateMnemonicOperandsAndComment (ExecutionContextScope *exe_scope) = 0;
+ CalculateMnemonicOperandsAndComment (const ExecutionContext* exe_ctx) = 0;
lldb::AddressClass
GetAddressClass ();
@@ -81,8 +81,7 @@
uint32_t max_opcode_byte_size,
bool show_address,
bool show_bytes,
- const ExecutionContext *exe_ctx,
- bool raw) = 0;
+ const ExecutionContext* exe_ctx);
virtual bool
DoesBranch () const = 0;
@@ -121,6 +120,9 @@
{
return m_opcode;
}
+
+ uint32_t
+ GetData (DataExtractor &data);
protected:
Address m_address; // The section offset address of this instruction
@@ -130,7 +132,9 @@
// The usual value will be eAddressClassCode, but often when
// disassembling memory, you might run into data. This can
// help us to disassemble appropriately.
- lldb::AddressClass m_address_class;
+private:
+ lldb::AddressClass m_address_class; // Use GetAddressClass () accessor function!
+protected:
Opcode m_opcode; // The opcode for this instruction
std::string m_opcode_name;
std::string m_mnemocics;
@@ -138,12 +142,12 @@
bool m_calculated_strings;
void
- CalculateMnemonicOperandsAndCommentIfNeeded (ExecutionContextScope *exe_scope)
+ CalculateMnemonicOperandsAndCommentIfNeeded (const ExecutionContext* exe_ctx)
{
if (!m_calculated_strings)
{
m_calculated_strings = true;
- CalculateMnemonicOperandsAndComment(exe_scope);
+ CalculateMnemonicOperandsAndComment(exe_ctx);
}
}
};
@@ -200,19 +204,11 @@
virtual
~PseudoInstruction ();
- virtual void
- Dump (Stream *s,
- uint32_t max_opcode_byte_size,
- bool show_address,
- bool show_bytes,
- const ExecutionContext* exe_ctx,
- bool raw);
-
virtual bool
DoesBranch () const;
virtual void
- CalculateMnemonicOperandsAndComment (ExecutionContextScope *exe_scope)
+ CalculateMnemonicOperandsAndComment (const ExecutionContext* exe_ctx)
{
// TODO: fill this in and put opcode name into Instruction::m_opcode_name,
// mnemonic into Instruction::m_mnemonics, and any comment into
Modified: lldb/branches/apple/python-GIL/include/lldb/Core/Opcode.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Core/Opcode.h?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Core/Opcode.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Core/Opcode.h Thu May 10 11:19:22 2012
@@ -67,6 +67,11 @@
SetOpcodeBytes (bytes, length);
}
+ void
+ Clear()
+ {
+ m_type = Opcode::eTypeInvalid;
+ }
Opcode::Type
GetType () const
{
@@ -205,9 +210,10 @@
return 0;
}
+ // Get the opcode exactly as it would be laid out in memory.
uint32_t
- GetData (DataExtractor &data) const;
-
+ GetData (DataExtractor &data,
+ lldb::AddressClass address_class) const;
protected:
@@ -240,8 +246,8 @@
uint64_t inst64;
struct
{
- uint8_t length;
uint8_t bytes[16]; // This must be big enough to handle any opcode for any supported target.
+ uint8_t length;
} inst;
} m_data;
};
Modified: lldb/branches/apple/python-GIL/include/lldb/Core/StreamString.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Core/StreamString.h?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Core/StreamString.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Core/StreamString.h Thu May 10 11:19:22 2012
@@ -49,6 +49,9 @@
const std::string &
GetString() const;
+ void
+ FillLastLineToColumn (uint32_t column, char fill_char);
+
protected:
std::string m_packet;
Modified: lldb/branches/apple/python-GIL/include/lldb/Target/Thread.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Target/Thread.h?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Target/Thread.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Target/Thread.h Thu May 10 11:19:22 2012
@@ -521,6 +521,11 @@
/// Gets the plan used to step through the code that steps from a function
/// call site at the current PC into the actual function call.
///
+ ///
+ /// @param[in] return_stack_id
+ /// The stack id that we will return to (by setting backstop breakpoints on the return
+ /// address to that frame) if we fail to step through.
+ ///
/// @param[in] abort_other_plans
/// \b true if we discard the currently queued plans and replace them with this one.
/// Otherwise this plan will go on the end of the plan stack.
@@ -532,7 +537,8 @@
/// A pointer to the newly queued thread plan, or NULL if the plan could not be queued.
//------------------------------------------------------------------
virtual ThreadPlan *
- QueueThreadPlanForStepThrough (bool abort_other_plans,
+ QueueThreadPlanForStepThrough (StackID &return_stack_id,
+ bool abort_other_plans,
bool stop_other_threads);
//------------------------------------------------------------------
Modified: lldb/branches/apple/python-GIL/include/lldb/Target/ThreadPlanCallFunction.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Target/ThreadPlanCallFunction.h?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Target/ThreadPlanCallFunction.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Target/ThreadPlanCallFunction.h Thu May 10 11:19:22 2012
@@ -139,7 +139,7 @@
lldb::addr_t &function_load_addr);
void
- DoTakedown ();
+ DoTakedown (bool success);
void
SetBreakpoints ();
Modified: lldb/branches/apple/python-GIL/include/lldb/Target/ThreadPlanStepThrough.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/include/lldb/Target/ThreadPlanStepThrough.h?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/include/lldb/Target/ThreadPlanStepThrough.h (original)
+++ lldb/branches/apple/python-GIL/include/lldb/Target/ThreadPlanStepThrough.h Thu May 10 11:19:22 2012
@@ -37,6 +37,7 @@
protected:
ThreadPlanStepThrough (Thread &thread,
+ StackID &return_stack_id,
bool stop_others);
void
@@ -47,14 +48,17 @@
private:
friend ThreadPlan *
- Thread::QueueThreadPlanForStepThrough (bool abort_other_plans,
+ Thread::QueueThreadPlanForStepThrough (StackID &return_stack_id,
+ bool abort_other_plans,
bool stop_others);
+
+ void ClearBackstopBreakpoint();
lldb::ThreadPlanSP m_sub_plan_sp;
lldb::addr_t m_start_address;
lldb::break_id_t m_backstop_bkpt_id;
lldb::addr_t m_backstop_addr;
- StackID m_stack_id;
+ StackID m_return_stack_id;
bool m_stop_others;
DISALLOW_COPY_AND_ASSIGN (ThreadPlanStepThrough);
Modified: lldb/branches/apple/python-GIL/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/lldb.xcodeproj/project.pbxproj?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/branches/apple/python-GIL/lldb.xcodeproj/project.pbxproj Thu May 10 11:19:22 2012
@@ -4296,6 +4296,7 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ CURRENT_PROJECT_VERSION = 146;
DEBUGGING_SYMBOLS = YES;
GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
@@ -4321,6 +4322,7 @@
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
+ CURRENT_PROJECT_VERSION = 146;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
@@ -4337,6 +4339,7 @@
ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
+ CURRENT_PROJECT_VERSION = 146;
GCC_ENABLE_OBJC_EXCEPTIONS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
MACOSX_DEPLOYMENT_TARGET = 10.7;
Modified: lldb/branches/apple/python-GIL/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original)
+++ lldb/branches/apple/python-GIL/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Thu May 10 11:19:22 2012
@@ -100,20 +100,6 @@
ReferencedContainer = "container:lldb.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
- <CommandLineArguments>
- <CommandLineArgument
- argument = "-a armv7 "
- isEnabled = "NO">
- </CommandLineArgument>
- <CommandLineArgument
- argument = "/Volumes/work/gclayton/Documents/devb/attach/a.out"
- isEnabled = "NO">
- </CommandLineArgument>
- <CommandLineArgument
- argument = "/bin/cat"
- isEnabled = "NO">
- </CommandLineArgument>
- </CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "LLDB_LAUNCH_FLAG_DISABLE_ASLR"
Modified: lldb/branches/apple/python-GIL/source/API/SBInstruction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/API/SBInstruction.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/API/SBInstruction.cpp (original)
+++ lldb/branches/apple/python-GIL/source/API/SBInstruction.cpp Thu May 10 11:19:22 2012
@@ -82,7 +82,7 @@
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}
- return m_opaque_sp->GetMnemonic(exe_ctx.GetBestExecutionContextScope());
+ return m_opaque_sp->GetMnemonic(&exe_ctx);
}
return NULL;
}
@@ -101,7 +101,7 @@
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}
- return m_opaque_sp->GetOperands(exe_ctx.GetBestExecutionContextScope());
+ return m_opaque_sp->GetOperands(&exe_ctx);
}
return NULL;
}
@@ -120,7 +120,7 @@
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}
- return m_opaque_sp->GetComment(exe_ctx.GetBestExecutionContextScope());
+ return m_opaque_sp->GetComment(&exe_ctx);
}
return NULL;
}
@@ -140,7 +140,7 @@
if (m_opaque_sp)
{
DataExtractorSP data_extractor_sp (new DataExtractor());
- if (m_opaque_sp->GetOpcode().GetData (*data_extractor_sp))
+ if (m_opaque_sp->GetData (*data_extractor_sp))
{
sb_data.SetOpaque (data_extractor_sp);
}
@@ -171,7 +171,7 @@
{
// Use the "ref()" instead of the "get()" accessor in case the SBStream
// didn't have a stream already created, one will get created...
- m_opaque_sp->Dump (&s.ref(), 0, true, false, NULL, false);
+ m_opaque_sp->Dump (&s.ref(), 0, true, false, NULL);
return true;
}
return false;
@@ -186,7 +186,7 @@
if (m_opaque_sp)
{
StreamFile out_stream (out, false);
- m_opaque_sp->Dump (&out_stream, 0, true, false, NULL, false);
+ m_opaque_sp->Dump (&out_stream, 0, true, false, NULL);
}
}
Modified: lldb/branches/apple/python-GIL/source/API/SBInstructionList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/API/SBInstructionList.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/API/SBInstructionList.cpp (original)
+++ lldb/branches/apple/python-GIL/source/API/SBInstructionList.cpp Thu May 10 11:19:22 2012
@@ -105,7 +105,7 @@
Instruction *inst = m_opaque_sp->GetInstructionList().GetInstructionAtIndex (i).get();
if (inst == NULL)
break;
- inst->Dump (&sref, max_opcode_byte_size, true, false, NULL, false);
+ inst->Dump (&sref, max_opcode_byte_size, true, false, NULL);
sref.EOL();
}
return true;
Modified: lldb/branches/apple/python-GIL/source/Core/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Core/Disassembler.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Core/Disassembler.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Core/Disassembler.cpp Thu May 10 11:19:22 2012
@@ -448,8 +448,7 @@
strm.PutCString(inst_is_at_pc ? "-> " : " ");
}
const bool show_bytes = (options & eOptionShowBytes) != 0;
- const bool raw = (options & eOptionRawOuput) != 0;
- inst->Dump(&strm, max_opcode_byte_size, true, show_bytes, &exe_ctx, raw);
+ inst->Dump(&strm, max_opcode_byte_size, true, show_bytes, &exe_ctx);
strm.EOL();
}
else
@@ -529,6 +528,69 @@
return m_address_class;
}
+void
+Instruction::Dump (lldb_private::Stream *s,
+ uint32_t max_opcode_byte_size,
+ bool show_address,
+ bool show_bytes,
+ const ExecutionContext* exe_ctx)
+{
+ const size_t opcode_column_width = 7;
+ const size_t operand_column_width = 25;
+
+ CalculateMnemonicOperandsAndCommentIfNeeded (exe_ctx);
+
+ StreamString ss;
+
+ if (show_address)
+ {
+ m_address.Dump(&ss,
+ exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL,
+ Address::DumpStyleLoadAddress,
+ Address::DumpStyleModuleWithFileAddress,
+ 0);
+
+ ss.PutCString(": ");
+ }
+
+ if (show_bytes)
+ {
+ if (m_opcode.GetType() == Opcode::eTypeBytes)
+ {
+ // x86_64 and i386 are the only ones that use bytes right now so
+ // pad out the byte dump to be able to always show 15 bytes (3 chars each)
+ // plus a space
+ if (max_opcode_byte_size > 0)
+ m_opcode.Dump (&ss, max_opcode_byte_size * 3 + 1);
+ else
+ m_opcode.Dump (&ss, 15 * 3 + 1);
+ }
+ else
+ {
+ // Else, we have ARM which can show up to a uint32_t 0x00000000 (10 spaces)
+ // plus two for padding...
+ if (max_opcode_byte_size > 0)
+ m_opcode.Dump (&ss, max_opcode_byte_size * 3 + 1);
+ else
+ m_opcode.Dump (&ss, 12);
+ }
+ }
+
+ const size_t opcode_pos = ss.GetSize();
+
+ ss.PutCString (m_opcode_name.c_str());
+ ss.FillLastLineToColumn (opcode_pos + opcode_column_width, ' ');
+ ss.PutCString (m_mnemocics.c_str());
+
+ if (!m_comment.empty())
+ {
+ ss.FillLastLineToColumn (opcode_pos + opcode_column_width + operand_column_width, ' ');
+ ss.PutCString (" ; ");
+ ss.PutCString (m_comment.c_str());
+ }
+ s->Write (ss.GetData(), ss.GetSize());
+}
+
bool
Instruction::DumpEmulation (const ArchSpec &arch)
{
@@ -828,6 +890,13 @@
return false;
}
+
+uint32_t
+Instruction::GetData (DataExtractor &data)
+{
+ return m_opcode.GetData(data, GetAddressClass ());
+}
+
InstructionList::InstructionList() :
m_instructions()
{
@@ -884,7 +953,7 @@
{
if (pos != begin)
s->EOL();
- (*pos)->Dump(s, max_opcode_byte_size, show_address, show_bytes, exe_ctx, false);
+ (*pos)->Dump(s, max_opcode_byte_size, show_address, show_bytes, exe_ctx);
}
}
@@ -1065,27 +1134,6 @@
{
}
-void
-PseudoInstruction::Dump (lldb_private::Stream *s,
- uint32_t max_opcode_byte_size,
- bool show_address,
- bool show_bytes,
- const lldb_private::ExecutionContext* exe_ctx,
- bool raw)
-{
- if (!s)
- return;
-
- if (show_bytes)
- m_opcode.Dump (s, max_opcode_byte_size);
-
- if (m_description.size() > 0)
- s->Printf ("%s", m_description.c_str());
- else
- s->Printf ("<unknown>");
-
-}
-
bool
PseudoInstruction::DoesBranch () const
{
Modified: lldb/branches/apple/python-GIL/source/Core/Opcode.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Core/Opcode.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Core/Opcode.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Core/Opcode.cpp Thu May 10 11:19:22 2012
@@ -1,4 +1,4 @@
-//===-- Baton.cpp -----------------------------------------------*- C++ -*-===//
+//===-- Opcode.cpp ----------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -12,12 +12,15 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
+#include "llvm/ADT/Triple.h"
// Project includes
+#include "lldb/Core/ArchSpec.h"
#include "lldb/Core/DataBufferHeap.h"
#include "lldb/Core/DataExtractor.h"
#include "lldb/Core/Stream.h"
#include "lldb/Host/Endian.h"
+
using namespace lldb;
using namespace lldb_private;
@@ -82,9 +85,10 @@
}
uint32_t
-Opcode::GetData (DataExtractor &data) const
+Opcode::GetData (DataExtractor &data, lldb::AddressClass address_class) const
{
uint32_t byte_size = GetByteSize ();
+
DataBufferSP buffer_sp;
if (byte_size > 0)
{
@@ -95,7 +99,27 @@
case Opcode::eType8: buffer_sp.reset (new DataBufferHeap (&m_data.inst8, byte_size)); break;
case Opcode::eType16: buffer_sp.reset (new DataBufferHeap (&m_data.inst16, byte_size)); break;
- case Opcode::eType32: buffer_sp.reset (new DataBufferHeap (&m_data.inst32, byte_size)); break;
+ case Opcode::eType32:
+ {
+ // The only thing that uses eAddressClassCodeAlternateISA currently
+ // is Thumb. If this ever changes, we will need to pass in more
+ // information like an additional "const ArchSpec &arch". For now
+ // this will do
+ if (address_class == eAddressClassCodeAlternateISA)
+ {
+ // 32 bit thumb instruction, we need to sizzle this a bit
+ uint8_t buf[4];
+ buf[0] = m_data.inst.bytes[2];
+ buf[1] = m_data.inst.bytes[3];
+ buf[2] = m_data.inst.bytes[0];
+ buf[3] = m_data.inst.bytes[1];
+ buffer_sp.reset (new DataBufferHeap (buf, byte_size));
+ break;
+ }
+ buffer_sp.reset (new DataBufferHeap (&m_data.inst32, byte_size));
+ }
+ break;
+
case Opcode::eType64: buffer_sp.reset (new DataBufferHeap (&m_data.inst64, byte_size)); break;
case Opcode::eTypeBytes:buffer_sp.reset (new DataBufferHeap (GetOpcodeBytes(), byte_size)); break;
break;
Modified: lldb/branches/apple/python-GIL/source/Core/StreamString.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Core/StreamString.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Core/StreamString.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Core/StreamString.cpp Thu May 10 11:19:22 2012
@@ -71,3 +71,24 @@
return m_packet;
}
+void
+StreamString::FillLastLineToColumn (uint32_t column, char fill_char)
+{
+ const size_t length = m_packet.size();
+ size_t last_line_begin_pos = m_packet.find_last_of("\r\n");
+ if (last_line_begin_pos == std::string::npos)
+ {
+ last_line_begin_pos = 0;
+ }
+ else
+ {
+ ++last_line_begin_pos;
+ }
+
+ const size_t line_columns = length - last_line_begin_pos;
+ if (column > line_columns)
+ {
+ m_packet.append(column - line_columns, fill_char);
+ }
+}
+
Modified: lldb/branches/apple/python-GIL/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Expression/ClangExpressionParser.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Expression/ClangExpressionParser.cpp Thu May 10 11:19:22 2012
@@ -793,8 +793,7 @@
max_opcode_byte_size,
true,
true,
- &exe_ctx,
- true);
+ &exe_ctx);
stream.PutChar('\n');
}
Modified: lldb/branches/apple/python-GIL/source/Expression/ExpressionSourceCode.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Expression/ExpressionSourceCode.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Expression/ExpressionSourceCode.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Expression/ExpressionSourceCode.cpp Thu May 10 11:19:22 2012
@@ -35,6 +35,8 @@
break;
case lldb::eLanguageTypeC:
wrap_stream.Printf("%s \n"
+ "#undef NULL \n"
+ "#define NULL 0 \n"
"typedef unsigned short unichar;\n"
"void \n"
"%s(void *$__lldb_arg) \n"
@@ -47,6 +49,8 @@
break;
case lldb::eLanguageTypeC_plus_plus:
wrap_stream.Printf("%s \n"
+ "#undef NULL \n"
+ "#define NULL 0 \n"
"typedef unsigned short unichar; \n"
"void \n"
"$__lldb_class::%s(void *$__lldb_arg) %s\n"
@@ -62,6 +66,8 @@
if (static_method)
{
wrap_stream.Printf("%s \n"
+ "#undef NULL \n"
+ "#define NULL 0 \n"
"typedef unsigned short unichar; \n"
"@interface $__lldb_objc_class ($__lldb_category) \n"
"+(void)%s:(void *)$__lldb_arg; \n"
@@ -79,7 +85,9 @@
}
else
{
- wrap_stream.Printf("%s \n"
+ wrap_stream.Printf("%s \n"
+ "#undef NULL \n"
+ "#define NULL 0 \n"
"typedef unsigned short unichar; \n"
"@interface $__lldb_objc_class ($__lldb_category) \n"
"-(void)%s:(void *)$__lldb_arg; \n"
Modified: lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Thu May 10 11:19:22 2012
@@ -165,285 +165,9 @@
}
#define AlignPC(pc_val) (pc_val & 0xFFFFFFFC)
-void
-InstructionLLVM::Dump
-(
- Stream *s,
- uint32_t max_opcode_byte_size,
- bool show_address,
- bool show_bytes,
- const ExecutionContext* exe_ctx,
- bool raw
-)
-{
- const size_t opcodeColumnWidth = 7;
- const size_t operandColumnWidth = 25;
-
- ExecutionContextScope *exe_scope = NULL;
- if (exe_ctx)
- exe_scope = exe_ctx->GetBestExecutionContextScope();
-
- // If we have an address, print it out
- if (GetAddress().IsValid() && show_address)
- {
- if (GetAddress().Dump (s,
- exe_scope,
- Address::DumpStyleLoadAddress,
- Address::DumpStyleModuleWithFileAddress,
- 0))
- s->PutCString(": ");
- }
-
- // If we are supposed to show bytes, "bytes" will be non-NULL.
- if (show_bytes)
- {
- if (m_opcode.GetType() == Opcode::eTypeBytes)
- {
- // x86_64 and i386 are the only ones that use bytes right now so
- // pad out the byte dump to be able to always show 15 bytes (3 chars each)
- // plus a space
- if (max_opcode_byte_size > 0)
- m_opcode.Dump (s, max_opcode_byte_size * 3 + 1);
- else
- m_opcode.Dump (s, 15 * 3 + 1);
- }
- else
- {
- // Else, we have ARM which can show up to a uint32_t 0x00000000 (10 spaces)
- // plus two for padding...
- if (max_opcode_byte_size > 0)
- m_opcode.Dump (s, max_opcode_byte_size * 3 + 1);
- else
- m_opcode.Dump (s, 12);
- }
- }
-
- int numTokens = -1;
-
- // FIXME!!!
- /* Remove the following section of code related to force_raw .... */
- /*
- bool force_raw = m_arch_type == llvm::Triple::arm ||
- m_arch_type == llvm::Triple::thumb;
- if (!raw)
- raw = force_raw;
- */
- /* .... when we fix the edis for arm/thumb. */
-
- if (!raw)
- numTokens = EDNumTokens(m_inst);
-
- int currentOpIndex = -1;
-
- bool printTokenized = false;
-
- if (numTokens != -1 && !raw)
- {
- addr_t base_addr = LLDB_INVALID_ADDRESS;
- uint32_t addr_nibble_size = 8;
- Target *target = NULL;
- if (exe_ctx)
- target = exe_ctx->GetTargetPtr();
- if (target)
- {
- if (!target->GetSectionLoadList().IsEmpty())
- base_addr = GetAddress().GetLoadAddress (target);
- addr_nibble_size = target->GetArchitecture().GetAddressByteSize() * 2;
- }
- if (base_addr == LLDB_INVALID_ADDRESS)
- base_addr = GetAddress().GetFileAddress ();
-
- lldb::addr_t PC = base_addr + EDInstByteSize(m_inst);
-
- // When executing an ARM instruction, PC reads as the address of the
- // current instruction plus 8. And for Thumb, it is plus 4.
- if (m_arch_type == llvm::Triple::arm)
- PC = base_addr + 8;
- else if (m_arch_type == llvm::Triple::thumb)
- PC = base_addr + 4;
-
- RegisterReaderArg rra(PC, m_disassembler);
-
- printTokenized = true;
-
- // Handle the opcode column.
-
- StreamString opcode;
-
- int tokenIndex = 0;
-
- EDTokenRef token;
- const char *tokenStr;
-
- if (EDGetToken(&token, m_inst, tokenIndex)) // 0 on success
- printTokenized = false;
- else if (!EDTokenIsOpcode(token))
- printTokenized = false;
- else if (EDGetTokenString(&tokenStr, token)) // 0 on success
- printTokenized = false;
-
- if (printTokenized)
- {
- // Put the token string into our opcode string
- opcode.PutCString(tokenStr);
-
- // If anything follows, it probably starts with some whitespace. Skip it.
- if (++tokenIndex < numTokens)
- {
- if (EDGetToken(&token, m_inst, tokenIndex)) // 0 on success
- printTokenized = false;
- else if (!EDTokenIsWhitespace(token))
- printTokenized = false;
- }
-
- ++tokenIndex;
- }
-
- // Handle the operands and the comment.
- StreamString operands;
- StreamString comment;
-
- if (printTokenized)
- {
- bool show_token = false;
-
- for (; tokenIndex < numTokens; ++tokenIndex)
- {
- if (EDGetToken(&token, m_inst, tokenIndex))
- return;
-
- int operandIndex = EDOperandIndexForToken(token);
-
- if (operandIndex >= 0)
- {
- if (operandIndex != currentOpIndex)
- {
- show_token = true;
-
- currentOpIndex = operandIndex;
- EDOperandRef operand;
-
- if (!EDGetOperand(&operand, m_inst, currentOpIndex))
- {
- if (EDOperandIsMemory(operand))
- {
- uint64_t operand_value;
-
- if (!EDEvaluateOperand(&operand_value, operand, IPRegisterReader, &rra))
- {
- if (EDInstIsBranch(m_inst))
- {
- operands.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);
- show_token = false;
- }
- else
- {
- // Put the address value into the comment
- comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);
- }
-
- AddSymbolicInfo(exe_ctx, comment, operand_value, GetAddress());
- } // EDEvaluateOperand
- } // EDOperandIsMemory
- } // EDGetOperand
- } // operandIndex != currentOpIndex
- } // operandIndex >= 0
-
- if (show_token)
- {
- if (EDGetTokenString(&tokenStr, token))
- {
- printTokenized = false;
- break;
- }
-
- operands.PutCString(tokenStr);
- }
- } // for (tokenIndex)
-
- // FIXME!!!
- // Workaround for llvm::tB's operands not properly parsed by ARMAsmParser.
- if (m_arch_type == llvm::Triple::thumb && opcode.GetString() == "b") {
- const char *inst_str;
- const char *pos = NULL;
- operands.Clear(); comment.Clear();
- if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) {
- uint64_t operand_value = PC + atoi(++pos);
- // Put the address value into the operands.
- operands.Printf("0x%8.8llx ", operand_value);
- AddSymbolicInfo(exe_ctx, comment, operand_value, GetAddress());
- }
- }
- // Yet more workaround for "bl #..." and "blx #...".
- if ((m_arch_type == llvm::Triple::arm || m_arch_type == llvm::Triple::thumb) &&
- (opcode.GetString() == "bl" || opcode.GetString() == "blx")) {
- const char *inst_str;
- const char *pos = NULL;
- operands.Clear(); comment.Clear();
- if (EDGetInstString(&inst_str, m_inst) == 0 && (pos = strstr(inst_str, "#")) != NULL) {
- if (m_arch_type == llvm::Triple::thumb && opcode.GetString() == "blx") {
- // A8.6.23 BLX (immediate)
- // Target Address = Align(PC,4) + offset value
- PC = AlignPC(PC);
- }
- uint64_t operand_value = PC + atoi(++pos);
- // Put the address value into the comment.
- comment.Printf("0x%8.8llx ", operand_value);
- // And the original token string into the operands.
- llvm::StringRef Str(pos - 1);
- RStrip(Str, '\n');
- operands.PutCString(Str.str().c_str());
- AddSymbolicInfo(exe_ctx, comment, operand_value, GetAddress());
- }
- }
- // END of workaround.
-
- // If both operands and comment are empty, we will just print out
- // the raw disassembly.
- if (operands.GetString().empty() && comment.GetString().empty())
- {
- const char *str;
-
- if (EDGetInstString(&str, m_inst))
- return;
- Align(s, str, opcodeColumnWidth, operandColumnWidth);
- }
- else
- {
- PadString(s, opcode.GetString(), opcodeColumnWidth);
-
- if (comment.GetString().empty())
- s->PutCString(operands.GetString().c_str());
- else
- {
- PadString(s, operands.GetString(), operandColumnWidth);
-
- s->PutCString("; ");
- s->PutCString(comment.GetString().c_str());
- } // else (comment.GetString().empty())
- } // else (operands.GetString().empty() && comment.GetString().empty())
- } // printTokenized
- } // numTokens != -1
-
- if (!printTokenized)
- {
- const char *str;
-
- if (EDGetInstString(&str, m_inst)) // 0 on success
- return;
- if (raw)
- s->Write(str, strlen(str) - 1);
- else
- {
- // EDis fails to parse the tokens of this inst. Need to align this
- // raw disassembly's opcode with the rest of output.
- Align(s, str, opcodeColumnWidth, operandColumnWidth);
- }
- }
-}
void
-InstructionLLVM::CalculateMnemonicOperandsAndComment (ExecutionContextScope *exe_scope)
+InstructionLLVM::CalculateMnemonicOperandsAndComment (const ExecutionContext* exe_ctx)
{
const int num_tokens = EDNumTokens(m_inst);
if (num_tokens > 0)
@@ -453,8 +177,7 @@
StreamString comment;
uint32_t addr_nibble_size = 8;
addr_t base_addr = LLDB_INVALID_ADDRESS;
- ExecutionContext exe_ctx (exe_scope);
- Target *target = exe_ctx.GetTargetPtr();
+ Target *target = exe_ctx ? exe_ctx->GetTargetPtr() : NULL;
if (target && !target->GetSectionLoadList().IsEmpty())
base_addr = GetAddress().GetLoadAddress (target);
if (base_addr == LLDB_INVALID_ADDRESS)
@@ -506,7 +229,7 @@
if (!EDEvaluateOperand(&operand_value, operand, IPRegisterReader, &rra))
{
comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);
- AddSymbolicInfo (&exe_ctx, comment, operand_value, GetAddress());
+ AddSymbolicInfo (exe_ctx, comment, operand_value, GetAddress());
}
}
}
@@ -531,7 +254,7 @@
uint64_t operand_value = PC + atoi(++pos);
// Put the address value into the operands.
comment.Printf("0x%*.*llx ", addr_nibble_size, addr_nibble_size, operand_value);
- AddSymbolicInfo (&exe_ctx, comment, operand_value, GetAddress());
+ AddSymbolicInfo (exe_ctx, comment, operand_value, GetAddress());
}
}
// Yet more workaround for "bl #..." and "blx #...".
@@ -556,7 +279,7 @@
// llvm::StringRef Str(pos - 1);
// RStrip(Str, '\n');
// operands.PutCString(Str.str().c_str());
- AddSymbolicInfo (&exe_ctx, comment, operand_value, GetAddress());
+ AddSymbolicInfo (exe_ctx, comment, operand_value, GetAddress());
}
}
// END of workaround.
Modified: lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Thu May 10 11:19:22 2012
@@ -27,14 +27,6 @@
virtual
~InstructionLLVM();
- virtual void
- Dump (lldb_private::Stream *s,
- uint32_t max_opcode_byte_size,
- bool show_address,
- bool show_bytes,
- const lldb_private::ExecutionContext* exe_ctx,
- bool raw);
-
virtual bool
DoesBranch () const;
@@ -44,7 +36,7 @@
uint32_t data_offset);
virtual void
- CalculateMnemonicOperandsAndComment (lldb_private::ExecutionContextScope *exe_scope);
+ CalculateMnemonicOperandsAndComment (const lldb_private::ExecutionContext* exe_ctx);
protected:
EDDisassemblerRef m_disassembler;
Modified: lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp Thu May 10 11:19:22 2012
@@ -36,8 +36,6 @@
Instruction(address, addr_class),
m_is_valid(false),
m_disasm(disasm),
- m_no_comments(true),
- m_comment_stream(),
m_does_branch(eLazyBoolCalculate)
{
}
@@ -58,137 +56,266 @@
ss.Printf("%*s", new_width - old_width, "");
}
}
-
- virtual void
- Dump (lldb_private::Stream *s,
- uint32_t max_opcode_byte_size,
- bool show_address,
- bool show_bytes,
- const lldb_private::ExecutionContext* exe_ctx,
- bool raw)
- {
- const size_t opcode_column_width = 7;
- const size_t operand_column_width = 25;
-
- StreamString ss;
- ExecutionContextScope *exe_scope = NULL;
+ virtual bool
+ DoesBranch () const
+ {
+ return m_does_branch == eLazyBoolYes;
+ }
+
+ virtual size_t
+ Decode (const lldb_private::Disassembler &disassembler,
+ const lldb_private::DataExtractor &data,
+ uint32_t data_offset)
+ {
+ // All we have to do is read the opcode which can be easy for some
+ // architetures
+ bool got_op = false;
+ const ArchSpec &arch = m_disasm.GetArchitecture();
- if ((!raw) && exe_ctx)
+ const uint32_t min_op_byte_size = arch.GetMinimumOpcodeByteSize();
+ const uint32_t max_op_byte_size = arch.GetMaximumOpcodeByteSize();
+ if (min_op_byte_size == max_op_byte_size)
{
- exe_scope = exe_ctx->GetBestExecutionContextScope();
+ // Fixed size instructions, just read that amount of data.
+ if (!data.ValidOffsetForDataOfSize(data_offset, min_op_byte_size))
+ return false;
+
+ switch (min_op_byte_size)
+ {
+ case 1:
+ m_opcode.SetOpcode8 (data.GetU8 (&data_offset));
+ got_op = true;
+ break;
+
+ case 2:
+ m_opcode.SetOpcode16 (data.GetU16 (&data_offset));
+ got_op = true;
+ break;
+
+ case 4:
+ m_opcode.SetOpcode32 (data.GetU32 (&data_offset));
+ got_op = true;
+ break;
+
+ case 8:
+ m_opcode.SetOpcode64 (data.GetU64 (&data_offset));
+ got_op = true;
+ break;
- DataExtractor extractor(m_raw_bytes.data(),
- m_raw_bytes.size(),
- m_disasm.GetArchitecture().GetByteOrder(),
- m_disasm.GetArchitecture().GetAddressByteSize());
-
- Parse <true> (m_address,
- m_address_class,
- extractor,
- 0,
- exe_scope);
+ default:
+ m_opcode.SetOpcodeBytes(data.PeekData(data_offset, min_op_byte_size), min_op_byte_size);
+ got_op = true;
+ break;
+ }
}
-
- if (show_address)
+ if (!got_op)
{
- m_address.Dump(&ss,
- exe_scope,
- Address::DumpStyleLoadAddress,
- Address::DumpStyleModuleWithFileAddress,
- 0);
+ ::LLVMDisasmContextRef disasm_context = m_disasm.m_disasm_context;
- ss.PutCString(": ");
- }
-
- if (show_bytes)
- {
- if (m_opcode.GetType() == Opcode::eTypeBytes)
+ bool is_altnernate_isa = false;
+ if (m_disasm.m_alternate_disasm_context)
+ {
+ const AddressClass address_class = GetAddressClass ();
+
+ if (address_class == eAddressClassCodeAlternateISA)
+ {
+ disasm_context = m_disasm.m_alternate_disasm_context;
+ is_altnernate_isa = true;
+ }
+ }
+ const llvm::Triple::ArchType machine = arch.GetMachine();
+ if (machine == llvm::Triple::arm || machine == llvm::Triple::thumb)
{
- // x86_64 and i386 are the only ones that use bytes right now so
- // pad out the byte dump to be able to always show 15 bytes (3 chars each)
- // plus a space
- if (max_opcode_byte_size > 0)
- m_opcode.Dump (&ss, max_opcode_byte_size * 3 + 1);
+ if (machine == llvm::Triple::thumb || is_altnernate_isa)
+ {
+ uint32_t thumb_opcode = data.GetU16(&data_offset);
+ if ((thumb_opcode & 0xe000) != 0xe000 || ((thumb_opcode & 0x1800u) == 0))
+ {
+ m_opcode.SetOpcode16 (thumb_opcode);
+ }
+ else
+ {
+ thumb_opcode <<= 16;
+ thumb_opcode |= data.GetU16(&data_offset);
+ m_opcode.SetOpcode32 (thumb_opcode);
+ m_is_valid = true;
+ }
+ }
else
- m_opcode.Dump (&ss, 15 * 3 + 1);
+ {
+ m_opcode.SetOpcode32 (data.GetU32(&data_offset));
+ }
}
else
{
- // Else, we have ARM which can show up to a uint32_t 0x00000000 (10 spaces)
- // plus two for padding...
- if (max_opcode_byte_size > 0)
- m_opcode.Dump (&ss, max_opcode_byte_size * 3 + 1);
+ // The opcode isn't evenly sized, so we need to actually use the llvm
+ // disassembler to parse it and get the size.
+ char out_string[512];
+ m_disasm.Lock(this, NULL);
+ uint8_t *opcode_data = const_cast<uint8_t *>(data.PeekData (data_offset, 1));
+ const size_t opcode_data_len = data.GetByteSize() - data_offset;
+ const addr_t pc = m_address.GetFileAddress();
+ const size_t inst_size = ::LLVMDisasmInstruction (disasm_context,
+ opcode_data,
+ opcode_data_len,
+ pc, // PC value
+ out_string,
+ sizeof(out_string));
+ // The address lookup function could have caused us to fill in our comment
+ m_comment.clear();
+ m_disasm.Unlock();
+ if (inst_size == 0)
+ m_opcode.Clear();
else
- m_opcode.Dump (&ss, 12);
- }
- }
-
- int size_before_inst = ss.GetSize();
-
- ss.PutCString(m_opcode_name.c_str());
-
- PadToWidth(ss, size_before_inst + opcode_column_width);
-
- ss.PutCString(m_mnemocics.c_str());
-
- PadToWidth(ss, size_before_inst + opcode_column_width + operand_column_width);
-
- if (!m_comment.empty())
- {
- ss.PutCString(" ; ");
- ss.PutCString(m_comment.c_str());
+ {
+ m_opcode.SetOpcodeBytes(opcode_data, inst_size);
+ m_is_valid = true;
+ }
+ }
}
-
- ss.Flush();
-
- s->PutCString(ss.GetData());
- }
-
- virtual bool
- DoesBranch () const
- {
- return m_does_branch == eLazyBoolYes;
- }
-
- virtual size_t
- Decode (const lldb_private::Disassembler &disassembler,
- const lldb_private::DataExtractor &data,
- uint32_t data_offset)
- {
- Parse <false> (m_address,
- m_address_class,
- data,
- data_offset,
- NULL);
-
return m_opcode.GetByteSize();
}
void
- AddReferencedAddress (std::string &description)
+ AppendComment (std::string &description)
{
- if (m_no_comments)
- m_comment_stream.PutCString(", ");
+ if (m_comment.empty())
+ m_comment.swap (description);
else
- m_no_comments = true;
-
- m_comment_stream.PutCString(description.c_str());
+ {
+ m_comment.append(", ");
+ m_comment.append(description);
+ }
}
virtual void
- CalculateMnemonicOperandsAndComment (lldb_private::ExecutionContextScope *exe_scope)
+ CalculateMnemonicOperandsAndComment (const lldb_private::ExecutionContext *exe_ctx)
{
- DataExtractor extractor(m_raw_bytes.data(),
- m_raw_bytes.size(),
- m_disasm.GetArchitecture().GetByteOrder(),
- m_disasm.GetArchitecture().GetAddressByteSize());
-
- Parse <true> (m_address,
- m_address_class,
- extractor,
- 0,
- exe_scope);
+ DataExtractor data;
+ const AddressClass address_class = GetAddressClass ();
+
+ if (m_opcode.GetData(data, address_class))
+ {
+ char out_string[512];
+
+ ::LLVMDisasmContextRef disasm_context;
+
+ if (address_class == eAddressClassCodeAlternateISA)
+ disasm_context = m_disasm.m_alternate_disasm_context;
+ else
+ disasm_context = m_disasm.m_disasm_context;
+
+ lldb::addr_t pc = LLDB_INVALID_ADDRESS;
+
+ if (exe_ctx)
+ {
+ Target *target = exe_ctx->GetTargetPtr();
+ if (target)
+ pc = m_address.GetLoadAddress(target);
+ }
+
+ if (pc == LLDB_INVALID_ADDRESS)
+ pc = m_address.GetFileAddress();
+
+ m_disasm.Lock(this, exe_ctx);
+ uint8_t *opcode_data = const_cast<uint8_t *>(data.PeekData (0, 1));
+ const size_t opcode_data_len = data.GetByteSize();
+ size_t inst_size = ::LLVMDisasmInstruction (disasm_context,
+ opcode_data,
+ opcode_data_len,
+ pc,
+ out_string,
+ sizeof(out_string));
+
+ m_disasm.Unlock();
+
+ if (inst_size == 0)
+ {
+ m_comment.assign ("unknown opcode");
+ inst_size = m_opcode.GetByteSize();
+ StreamString mnemonic_strm;
+ uint32_t offset = 0;
+ switch (inst_size)
+ {
+ case 1:
+ {
+ const uint8_t uval8 = data.GetU8 (&offset);
+ m_opcode.SetOpcode8 (uval8);
+ m_opcode_name.assign (".byte");
+ mnemonic_strm.Printf("0x%2.2x", uval8);
+ }
+ break;
+ case 2:
+ {
+ const uint16_t uval16 = data.GetU16(&offset);
+ m_opcode.SetOpcode16(uval16);
+ m_opcode_name.assign (".short");
+ mnemonic_strm.Printf("0x%4.4x", uval16);
+ }
+ break;
+ case 4:
+ {
+ const uint32_t uval32 = data.GetU32(&offset);
+ m_opcode.SetOpcode32(uval32);
+ m_opcode_name.assign (".long");
+ mnemonic_strm.Printf("0x%8.8x", uval32);
+ }
+ break;
+ case 8:
+ {
+ const uint64_t uval64 = data.GetU64(&offset);
+ m_opcode.SetOpcode64(uval64);
+ m_opcode_name.assign (".quad");
+ mnemonic_strm.Printf("0x%16.16llx", uval64);
+ }
+ break;
+ default:
+ if (inst_size == 0)
+ return;
+ else
+ {
+ const uint8_t *bytes = data.PeekData(offset, inst_size);
+ if (bytes == NULL)
+ return;
+ m_opcode_name.assign (".byte");
+ m_opcode.SetOpcodeBytes(bytes, inst_size);
+ mnemonic_strm.Printf("0x%2.2x", bytes[0]);
+ for (uint32_t i=1; i<inst_size; ++i)
+ mnemonic_strm.Printf(" 0x%2.2x", bytes[i]);
+ }
+ break;
+ }
+ m_mnemocics.swap(mnemonic_strm.GetString());
+ return;
+ }
+ else
+ {
+ if (m_does_branch == eLazyBoolCalculate)
+ {
+ if (StringRepresentsBranch (out_string, strlen(out_string)))
+ m_does_branch = eLazyBoolYes;
+ else
+ m_does_branch = eLazyBoolNo;
+ }
+ }
+
+ if (!s_regex_compiled)
+ {
+ ::regcomp(&s_regex, "[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?", REG_EXTENDED);
+ s_regex_compiled = true;
+ }
+
+ ::regmatch_t matches[3];
+
+ if (!::regexec(&s_regex, out_string, sizeof(matches) / sizeof(::regmatch_t), matches, 0))
+ {
+ if (matches[1].rm_so != -1)
+ m_opcode_name.assign(out_string + matches[1].rm_so, matches[1].rm_eo - matches[1].rm_so);
+ if (matches[2].rm_so != -1)
+ m_mnemocics.assign(out_string + matches[2].rm_so, matches[2].rm_eo - matches[2].rm_so);
+ }
+ }
}
bool
@@ -203,69 +330,6 @@
return m_opcode.GetByteSize();
}
protected:
- void PopulateOpcode (const DataExtractor &extractor,
- uint32_t offset,
- size_t inst_size)
- {
- const ArchSpec &arch = m_disasm.GetArchitecture();
- llvm::Triple::ArchType machine = arch.GetMachine();
-
- switch (machine)
- {
- case llvm::Triple::x86:
- case llvm::Triple::x86_64:
- m_opcode.SetOpcodeBytes(extractor.PeekData(offset, inst_size), inst_size);
- return;
-
- case llvm::Triple::arm:
- case llvm::Triple::thumb:
- switch (inst_size)
- {
- case 2:
- m_opcode.SetOpcode16 (extractor.GetU16 (&offset));
- break;
- case 4:
- if (machine == llvm::Triple::arm && m_address_class == eAddressClassCodeAlternateISA)
- {
- // If it is a 32-bit THUMB instruction, we need to swap the upper & lower halves.
- uint32_t orig_bytes = extractor.GetU32 (&offset);
- uint16_t upper_bits = (orig_bytes >> 16) & ((1u << 16) - 1);
- uint16_t lower_bits = orig_bytes & ((1u << 16) - 1);
- uint32_t swapped = (lower_bits << 16) | upper_bits;
- m_opcode.SetOpcode32 (swapped);
- }
- else
- {
- m_opcode.SetOpcode32 (extractor.GetU32 (&offset));
- }
- break;
- default:
- assert (!"Invalid ARM opcode size");
- break;
- }
- return;
-
- default:
- break;
- }
- // Handle the default cases here.
- const uint32_t min_op_byte_size = arch.GetMinimumOpcodeByteSize();
- const uint32_t max_op_byte_size = arch.GetMaximumOpcodeByteSize();
- if (min_op_byte_size == max_op_byte_size)
- {
- assert (inst_size == min_op_byte_size);
- switch (inst_size)
- {
- case 1: m_opcode.SetOpcode8 (extractor.GetU8 (&offset)); return;
- case 2: m_opcode.SetOpcode16 (extractor.GetU16 (&offset)); return;
- case 4: m_opcode.SetOpcode32 (extractor.GetU32 (&offset)); return;
- case 8: m_opcode.SetOpcode64 (extractor.GetU64 (&offset)); return;
- default:
- break;
- }
- }
- m_opcode.SetOpcodeBytes(extractor.PeekData(offset, inst_size), inst_size);
- }
bool StringRepresentsBranch (const char *data, size_t size)
{
@@ -349,99 +413,8 @@
return false;
}
- template <bool Reparse> bool Parse (const lldb_private::Address &address,
- AddressClass addr_class,
- const DataExtractor &extractor,
- uint32_t data_offset,
- lldb_private::ExecutionContextScope *exe_scope)
- {
- std::vector<char> out_string(256);
-
- const uint8_t *data_start = extractor.GetDataStart();
-
- m_disasm.Lock(this, exe_scope);
-
- ::LLVMDisasmContextRef disasm_context;
-
- if (addr_class == eAddressClassCodeAlternateISA)
- disasm_context = m_disasm.m_alternate_disasm_context;
- else
- disasm_context = m_disasm.m_disasm_context;
-
- m_comment_stream.Clear();
-
- lldb::addr_t pc = LLDB_INVALID_ADDRESS;
-
- if (exe_scope)
- if (TargetSP target_sp = exe_scope->CalculateTarget())
- pc = m_address.GetLoadAddress(target_sp.get());
-
- if (pc == LLDB_INVALID_ADDRESS)
- pc = m_address.GetFileAddress();
-
- size_t inst_size = ::LLVMDisasmInstruction(disasm_context,
- const_cast<uint8_t*>(data_start) + data_offset,
- extractor.GetByteSize() - data_offset,
- pc,
- out_string.data(),
- out_string.size());
-
- if (m_does_branch == eLazyBoolCalculate)
- m_does_branch = (StringRepresentsBranch (out_string.data(), out_string.size()) ?
- eLazyBoolYes : eLazyBoolNo);
-
- m_comment_stream.Flush();
- m_no_comments = false;
-
- m_comment.swap(m_comment_stream.GetString());
-
- m_disasm.Unlock();
-
- if (Reparse)
- {
- if (inst_size != m_raw_bytes.size())
- return false;
- }
- else
- {
- if (!inst_size)
- return false;
- }
-
- PopulateOpcode(extractor, data_offset, inst_size);
-
- m_raw_bytes.resize(inst_size);
- memcpy(m_raw_bytes.data(), data_start + data_offset, inst_size);
-
- if (!s_regex_compiled)
- {
- ::regcomp(&s_regex, "[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?", REG_EXTENDED);
- s_regex_compiled = true;
- }
-
- ::regmatch_t matches[3];
-
- const char *out_data = out_string.data();
-
- if (!::regexec(&s_regex, out_data, sizeof(matches) / sizeof(::regmatch_t), matches, 0))
- {
- if (matches[1].rm_so != -1)
- m_opcode_name.assign(out_data + matches[1].rm_so, matches[1].rm_eo - matches[1].rm_so);
- if (matches[2].rm_so != -1)
- m_mnemocics.assign(out_data + matches[2].rm_so, matches[2].rm_eo - matches[2].rm_so);
- }
-
- m_is_valid = true;
-
- return true;
- }
-
bool m_is_valid;
DisassemblerLLVMC &m_disasm;
- std::vector<uint8_t> m_raw_bytes;
-
- bool m_no_comments;
- StreamString m_comment_stream;
LazyBool m_does_branch;
static bool s_regex_compiled;
@@ -464,8 +437,10 @@
DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch) :
Disassembler(arch),
- m_disasm_context(NULL),
- m_alternate_disasm_context(NULL)
+ m_exe_ctx (NULL),
+ m_inst (NULL),
+ m_disasm_context (NULL),
+ m_alternate_disasm_context (NULL)
{
m_disasm_context = ::LLVMCreateDisasm(arch.GetTriple().getTriple().c_str(),
(void*)this,
@@ -475,7 +450,11 @@
if (arch.GetTriple().getArch() == llvm::Triple::arm)
{
- m_alternate_disasm_context = ::LLVMCreateDisasm("thumbv7-apple-darwin",
+ ArchSpec thumb_arch(arch);
+ thumb_arch.GetTriple().setArchName(llvm::StringRef("thumbv7"));
+ std::string thumb_triple(thumb_arch.GetTriple().getTriple());
+
+ m_alternate_disasm_context = ::LLVMCreateDisasm(thumb_triple.c_str(),
(void*)this,
/*TagType=*/1,
NULL,
@@ -511,39 +490,33 @@
return 0;
uint32_t data_cursor = data_offset;
- size_t data_byte_size = data.GetByteSize();
+ const size_t data_byte_size = data.GetByteSize();
uint32_t instructions_parsed = 0;
+ Address inst_addr(base_addr);
- uint64_t instruction_pointer = base_addr.GetFileAddress();
-
- std::vector<char> out_string(256);
-
- while (data_offset < data_byte_size && instructions_parsed < num_instructions)
+ while (data_cursor < data_byte_size && instructions_parsed < num_instructions)
{
- Address instr_address = base_addr;
- instr_address.Slide(data_cursor);
- AddressClass address_class = eAddressClassUnknown;
+ AddressClass address_class = eAddressClassCode;
if (m_alternate_disasm_context)
- address_class = instr_address.GetAddressClass ();
+ address_class = inst_addr.GetAddressClass ();
InstructionSP inst_sp(new InstructionLLVMC(*this,
- instr_address,
+ inst_addr,
address_class));
if (!inst_sp)
- return data_cursor - data_offset;
-
+ break;
+
uint32_t inst_size = inst_sp->Decode(*this, data, data_cursor);
- if (!inst_size)
- return data_cursor - data_offset;
-
+ if (inst_size == 0)
+ break;
+
m_instruction_list.Append(inst_sp);
-
- instruction_pointer += inst_size;
data_cursor += inst_size;
+ inst_addr.Slide(inst_size);
instructions_parsed++;
}
@@ -582,73 +555,72 @@
return "Disassembler that uses LLVM MC to disassemble i386, x86_64 and ARM.";
}
-int DisassemblerLLVMC::OpInfoCallback (void *DisInfo,
- uint64_t PC,
- uint64_t Offset,
- uint64_t Size,
- int TagType,
- void *TagBug)
-{
- return static_cast<DisassemblerLLVMC*>(DisInfo)->OpInfo(PC,
- Offset,
- Size,
- TagType,
- TagBug);
-}
-
-const char *DisassemblerLLVMC::SymbolLookupCallback(void *DisInfo,
- uint64_t ReferenceValue,
- uint64_t *ReferenceType,
- uint64_t ReferencePC,
- const char **ReferenceName)
-{
- return static_cast<DisassemblerLLVMC*>(DisInfo)->SymbolLookup(ReferenceValue,
- ReferenceType,
- ReferencePC,
- ReferenceName);
+int DisassemblerLLVMC::OpInfoCallback (void *disassembler,
+ uint64_t pc,
+ uint64_t offset,
+ uint64_t size,
+ int tag_type,
+ void *tag_bug)
+{
+ return static_cast<DisassemblerLLVMC*>(disassembler)->OpInfo (pc,
+ offset,
+ size,
+ tag_type,
+ tag_bug);
+}
+
+const char *DisassemblerLLVMC::SymbolLookupCallback (void *disassembler,
+ uint64_t value,
+ uint64_t *type,
+ uint64_t pc,
+ const char **name)
+{
+ return static_cast<DisassemblerLLVMC*>(disassembler)->SymbolLookup(value,
+ type,
+ pc,
+ name);
}
int DisassemblerLLVMC::OpInfo (uint64_t PC,
uint64_t Offset,
uint64_t Size,
- int TagType,
- void *TagBug)
+ int tag_type,
+ void *tag_bug)
{
- switch (TagType)
+ switch (tag_type)
{
default:
break;
case 1:
- bzero (TagBug, sizeof(::LLVMOpInfo1));
+ bzero (tag_bug, sizeof(::LLVMOpInfo1));
break;
}
return 0;
}
-const char *DisassemblerLLVMC::SymbolLookup (uint64_t ReferenceValue,
- uint64_t *ReferenceType,
- uint64_t ReferencePC,
- const char **ReferenceName)
-{
- const char *result_name = NULL;
- uint64_t result_reference_type = LLVMDisassembler_ReferenceType_InOut_None;
- const char *result_referred_name = NULL;
-
- if (m_exe_scope && m_inst)
- {
- Address reference_address;
-
- TargetSP target_sp (m_exe_scope->CalculateTarget());
- Target *target = target_sp.get();
-
- if (target)
- {
- if (!target->GetSectionLoadList().ResolveLoadAddress(ReferenceValue, reference_address))
+const char *DisassemblerLLVMC::SymbolLookup (uint64_t value,
+ uint64_t *type_ptr,
+ uint64_t pc,
+ const char **name)
+{
+ if (*type_ptr)
+ {
+ if (m_exe_ctx && m_inst)
+ {
+ //std::string remove_this_prior_to_checkin;
+ Address reference_address;
+
+ Target *target = m_exe_ctx ? m_exe_ctx->GetTargetPtr() : NULL;
+
+ if (target && !target->GetSectionLoadList().IsEmpty())
+ target->GetSectionLoadList().ResolveLoadAddress(value, reference_address);
+ else
{
- if (ModuleSP module_sp = m_inst->GetAddress().GetModule())
- module_sp->ResolveFileAddress(ReferenceValue, reference_address);
+ ModuleSP module_sp(m_inst->GetAddress().GetModule());
+ if (module_sp)
+ module_sp->ResolveFileAddress(value, reference_address);
}
-
+
if (reference_address.IsValid() && reference_address.GetSection())
{
StreamString ss;
@@ -659,15 +631,19 @@
Address::DumpStyleSectionNameOffset);
if (!ss.GetString().empty())
- m_inst->AddReferencedAddress(ss.GetString());
+ {
+ //remove_this_prior_to_checkin = ss.GetString();
+ //if (*type_ptr)
+ m_inst->AppendComment(ss.GetString());
+ }
}
+ //printf ("DisassemblerLLVMC::SymbolLookup (value=0x%16.16llx, type=%llu, pc=0x%16.16llx, name=\"%s\") m_exe_ctx=%p, m_inst=%p\n", value, *type_ptr, pc, remove_this_prior_to_checkin.c_str(), m_exe_ctx, m_inst);
}
}
-
- *ReferenceType = result_reference_type;
- *ReferenceName = result_referred_name;
-
- return result_name;
+
+ *type_ptr = LLVMDisassembler_ReferenceType_InOut_None;
+ *name = NULL;
+ return NULL;
}
//------------------------------------------------------------------
Modified: lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.h Thu May 10 11:19:22 2012
@@ -100,27 +100,25 @@
const char **ReferenceName);
void Lock(InstructionLLVMC *inst,
- lldb_private::ExecutionContextScope *exe_scope)
+ const lldb_private::ExecutionContext *exe_ctx)
{
m_mutex.Lock();
-
m_inst = inst;
- m_exe_scope = exe_scope;
+ m_exe_ctx = exe_ctx;
}
void Unlock()
{
- m_exe_scope = NULL;
m_inst = NULL;
-
+ m_exe_ctx = NULL;
m_mutex.Unlock();
}
- lldb_private::ExecutionContextScope *m_exe_scope;
- InstructionLLVMC *m_inst;
- lldb_private::Mutex m_mutex;
- ::LLVMDisasmContextRef m_disasm_context;
- ::LLVMDisasmContextRef m_alternate_disasm_context;
+ const lldb_private::ExecutionContext *m_exe_ctx;
+ InstructionLLVMC *m_inst;
+ lldb_private::Mutex m_mutex;
+ ::LLVMDisasmContextRef m_disasm_context;
+ ::LLVMDisasmContextRef m_alternate_disasm_context;
};
#endif // liblldb_DisassemblerLLVM_h_
Modified: lldb/branches/apple/python-GIL/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleThreadPlanStepThroughObjCTrampoline.cpp Thu May 10 11:19:22 2012
@@ -125,9 +125,10 @@
bool
AppleThreadPlanStepThroughObjCTrampoline::PlanExplainsStop ()
{
- // This plan should actually never stop when it is on the top of the plan
- // stack, since it does all it's running in client plans.
- return false;
+ // If we get asked to explain the stop it will be because something went
+ // wrong (like the implementation for selector function crashed... We're going
+ // to figure out what to do about that, so we do explain the stop.
+ return true;
}
lldb::StateType
@@ -139,66 +140,83 @@
bool
AppleThreadPlanStepThroughObjCTrampoline::ShouldStop (Event *event_ptr)
{
- if (m_func_sp.get() == NULL || m_thread.IsThreadPlanDone(m_func_sp.get()))
+ // First stage: we are still handling the "call a function to get the target of the dispatch"
+ if (m_func_sp)
{
- m_func_sp.reset();
- if (!m_run_to_sp)
+ if (!m_func_sp->IsPlanComplete())
+ {
+ return false;
+ }
+ else
{
- Value target_addr_value;
- ExecutionContext exc_ctx;
- m_thread.CalculateExecutionContext(exc_ctx);
- m_impl_function->FetchFunctionResults (exc_ctx, m_args_addr, target_addr_value);
- m_impl_function->DeallocateFunctionResults(exc_ctx, m_args_addr);
- lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong();
- Address target_so_addr;
- target_so_addr.SetOpcodeLoadAddress(target_addr, exc_ctx.GetTargetPtr());
- LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
- if (target_addr == 0)
+ if (!m_func_sp->PlanSucceeded())
{
- if (log)
- log->Printf("Got target implementation of 0x0, stopping.");
- SetPlanComplete();
+ SetPlanComplete(false);
return true;
}
- if (m_trampoline_handler->AddrIsMsgForward(target_addr))
- {
- if (log)
- log->Printf ("Implementation lookup returned msgForward function: 0x%llx, stopping.", target_addr);
-
- SymbolContext sc = m_thread.GetStackFrameAtIndex(0)->GetSymbolContext(eSymbolContextEverything);
- m_run_to_sp.reset(new ThreadPlanStepOut (m_thread,
- &sc,
- true,
- m_stop_others,
- eVoteNoOpinion,
- eVoteNoOpinion,
- 0));
- m_thread.QueueThreadPlan(m_run_to_sp, false);
- m_run_to_sp->SetPrivate(true);
- return false;
- }
-
+ m_func_sp.reset();
+ }
+ }
+
+ // Second stage, if all went well with the function calling, then fetch the target address, and
+ // queue up a "run to that address" plan.
+ if (!m_run_to_sp)
+ {
+ Value target_addr_value;
+ ExecutionContext exc_ctx;
+ m_thread.CalculateExecutionContext(exc_ctx);
+ m_impl_function->FetchFunctionResults (exc_ctx, m_args_addr, target_addr_value);
+ m_impl_function->DeallocateFunctionResults(exc_ctx, m_args_addr);
+ lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong();
+ Address target_so_addr;
+ target_so_addr.SetOpcodeLoadAddress(target_addr, exc_ctx.GetTargetPtr());
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
+ if (target_addr == 0)
+ {
if (log)
- log->Printf("Running to ObjC method implementation: 0x%llx", target_addr);
-
- ObjCLanguageRuntime *objc_runtime = GetThread().GetProcess()->GetObjCLanguageRuntime();
- assert (objc_runtime != NULL);
- objc_runtime->AddToMethodCache (m_isa_addr, m_sel_addr, target_addr);
+ log->Printf("Got target implementation of 0x0, stopping.");
+ SetPlanComplete();
+ return true;
+ }
+ if (m_trampoline_handler->AddrIsMsgForward(target_addr))
+ {
if (log)
- log->Printf("Adding {isa-addr=0x%llx, sel-addr=0x%llx} = addr=0x%llx to cache.", m_isa_addr, m_sel_addr, target_addr);
+ log->Printf ("Implementation lookup returned msgForward function: 0x%llx, stopping.", target_addr);
- // Extract the target address from the value:
-
- m_run_to_sp.reset(new ThreadPlanRunToAddress(m_thread, target_so_addr, m_stop_others));
+ SymbolContext sc = m_thread.GetStackFrameAtIndex(0)->GetSymbolContext(eSymbolContextEverything);
+ m_run_to_sp.reset(new ThreadPlanStepOut (m_thread,
+ &sc,
+ true,
+ m_stop_others,
+ eVoteNoOpinion,
+ eVoteNoOpinion,
+ 0));
m_thread.QueueThreadPlan(m_run_to_sp, false);
m_run_to_sp->SetPrivate(true);
return false;
}
- else if (m_thread.IsThreadPlanDone(m_run_to_sp.get()))
- {
- SetPlanComplete();
- return true;
- }
+
+ if (log)
+ log->Printf("Running to ObjC method implementation: 0x%llx", target_addr);
+
+ ObjCLanguageRuntime *objc_runtime = GetThread().GetProcess()->GetObjCLanguageRuntime();
+ assert (objc_runtime != NULL);
+ objc_runtime->AddToMethodCache (m_isa_addr, m_sel_addr, target_addr);
+ if (log)
+ log->Printf("Adding {isa-addr=0x%llx, sel-addr=0x%llx} = addr=0x%llx to cache.", m_isa_addr, m_sel_addr, target_addr);
+
+ // Extract the target address from the value:
+
+ m_run_to_sp.reset(new ThreadPlanRunToAddress(m_thread, target_so_addr, m_stop_others));
+ m_thread.QueueThreadPlan(m_run_to_sp, false);
+ m_run_to_sp->SetPrivate(true);
+ return false;
+ }
+ else if (m_thread.IsThreadPlanDone(m_run_to_sp.get()))
+ {
+ // Third stage, work the run to target plan.
+ SetPlanComplete();
+ return true;
}
return false;
}
Modified: lldb/branches/apple/python-GIL/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.cpp Thu May 10 11:19:22 2012
@@ -71,7 +71,6 @@
const uint32_t addr_byte_size = m_arch.GetAddressByteSize();
const bool show_address = true;
const bool show_bytes = true;
- const bool raw = false;
// Initialize the CFA with a known value. In the 32 bit case
// it will be 0x80000000, and in the 64 bit case 0x8000000000000000.
// We use the address byte size to be safe for any future addresss sizes
@@ -107,7 +106,7 @@
if (log && log->GetVerbose ())
{
StreamString strm;
- inst->Dump(&strm, inst_list.GetMaxOpcocdeByteSize (), show_address, show_bytes, &exe_ctx, raw);
+ inst->Dump(&strm, inst_list.GetMaxOpcocdeByteSize (), show_address, show_bytes, NULL);
log->PutCString (strm.GetData());
}
Modified: lldb/branches/apple/python-GIL/source/Symbol/SymbolContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Symbol/SymbolContext.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Symbol/SymbolContext.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Symbol/SymbolContext.cpp Thu May 10 11:19:22 2012
@@ -203,6 +203,8 @@
if (symbol->GetMangled().GetName())
{
dumped_something = true;
+ if (symbol->GetType() == eSymbolTypeTrampoline)
+ s->PutCString("symbol stub for: ");
symbol->GetMangled().GetName().Dump(s);
}
Modified: lldb/branches/apple/python-GIL/source/Target/Thread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/Thread.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/Thread.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/Thread.cpp Thu May 10 11:19:22 2012
@@ -976,9 +976,9 @@
}
ThreadPlan *
-Thread::QueueThreadPlanForStepThrough (bool abort_other_plans, bool stop_other_threads)
+Thread::QueueThreadPlanForStepThrough (StackID &return_stack_id, bool abort_other_plans, bool stop_other_threads)
{
- ThreadPlanSP thread_plan_sp(new ThreadPlanStepThrough (*this, stop_other_threads));
+ ThreadPlanSP thread_plan_sp(new ThreadPlanStepThrough (*this, return_stack_id, stop_other_threads));
if (!thread_plan_sp || !thread_plan_sp->ValidatePlan (NULL))
return NULL;
Modified: lldb/branches/apple/python-GIL/source/Target/ThreadPlan.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/ThreadPlan.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/ThreadPlan.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/ThreadPlan.cpp Thu May 10 11:19:22 2012
@@ -69,6 +69,7 @@
ThreadPlan::MischiefManaged ()
{
Mutex::Locker locker(m_plan_complete_mutex);
+ // Mark the plan is complete, but don't override the success flag.
m_plan_complete = true;
return true;
}
Modified: lldb/branches/apple/python-GIL/source/Target/ThreadPlanCallFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/ThreadPlanCallFunction.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/ThreadPlanCallFunction.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/ThreadPlanCallFunction.cpp Thu May 10 11:19:22 2012
@@ -228,7 +228,7 @@
ThreadPlanCallFunction::~ThreadPlanCallFunction ()
{
- DoTakedown();
+ DoTakedown(true);
}
void
@@ -260,7 +260,7 @@
}
void
-ThreadPlanCallFunction::DoTakedown ()
+ThreadPlanCallFunction::DoTakedown (bool success)
{
LogSP log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_STEP));
@@ -274,21 +274,23 @@
if (!m_takedown_done)
{
- ProcessSP process_sp (m_thread.GetProcess());
- const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
- if (abi && m_return_type.IsValid())
+ if (success)
{
- const bool persistent = false;
- m_return_valobj_sp = abi->GetReturnValueObject (m_thread, m_return_type, persistent);
+ ProcessSP process_sp (m_thread.GetProcess());
+ const ABI *abi = process_sp ? process_sp->GetABI().get() : NULL;
+ if (abi && m_return_type.IsValid())
+ {
+ const bool persistent = false;
+ m_return_valobj_sp = abi->GetReturnValueObject (m_thread, m_return_type, persistent);
+ }
}
-
if (log)
log->Printf ("ThreadPlanCallFunction(%p): DoTakedown called for thread 0x%4.4llx, m_valid: %d complete: %d.\n", this, m_thread.GetID(), m_valid, IsPlanComplete());
m_takedown_done = true;
m_stop_address = m_thread.GetStackFrameAtIndex(0)->GetRegisterContext()->GetPC();
m_real_stop_info_sp = GetPrivateStopReason();
m_thread.RestoreThreadStateFromCheckpoint(m_stored_thread_state);
- SetPlanComplete();
+ SetPlanComplete(success);
ClearBreakpoints();
if (log && log->GetVerbose())
ReportRegisterState ("Restoring thread state after function call. Restored register state:");
@@ -304,7 +306,7 @@
void
ThreadPlanCallFunction::WillPop ()
{
- DoTakedown();
+ DoTakedown(true);
}
void
@@ -342,7 +344,13 @@
// Check if the breakpoint is one of ours.
- if (BreakpointsExplainStop())
+ StopReason stop_reason;
+ if (!m_real_stop_info_sp)
+ stop_reason = eStopReasonNone;
+ else
+ stop_reason = m_real_stop_info_sp->GetStopReason();
+
+ if (stop_reason == eStopReasonBreakpoint && BreakpointsExplainStop())
return true;
// If we don't want to discard this plan, than any stop we don't understand should be propagated up the stack.
@@ -352,7 +360,8 @@
// Otherwise, check the case where we stopped for an internal breakpoint, in that case, continue on.
// If it is not an internal breakpoint, consult OkayToDiscard.
- if (m_real_stop_info_sp && m_real_stop_info_sp->GetStopReason() == eStopReasonBreakpoint)
+
+ if (stop_reason == eStopReasonBreakpoint)
{
ProcessSP process_sp (m_thread.CalculateProcess());
uint64_t break_site_id = m_real_stop_info_sp->GetValue();
@@ -385,7 +394,18 @@
// If we want to discard the plan, then we say we explain the stop
// but if we are going to be discarded, let whoever is above us
// explain the stop.
- return ((m_subplan_sp.get() != NULL) && !OkayToDiscard());
+ if (m_subplan_sp != NULL)
+ {
+ if (OkayToDiscard())
+ {
+ DoTakedown(false);
+ return true;
+ }
+ else
+ return false;
+ }
+ else
+ return false;
}
}
@@ -396,7 +416,7 @@
{
ReportRegisterState ("Function completed. Register state was:");
- DoTakedown();
+ DoTakedown(true);
return true;
}
Modified: lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepInRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepInRange.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepInRange.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepInRange.cpp Thu May 10 11:19:22 2012
@@ -104,7 +104,7 @@
// A caveat to this is if we think the frame is older but we're actually in a trampoline.
// I'm going to make the assumption that you wouldn't RETURN to a trampoline. So if we are
// in a trampoline we think the frame is older because the trampoline confused the backtracer.
- new_plan = m_thread.QueueThreadPlanForStepThrough (false, stop_others);
+ new_plan = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
if (new_plan == NULL)
return true;
else if (log)
@@ -140,7 +140,7 @@
// We may have set the plan up above in the FrameIsOlder section:
if (new_plan == NULL)
- new_plan = m_thread.QueueThreadPlanForStepThrough (false, stop_others);
+ new_plan = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
if (log)
{
Modified: lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepOverRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepOverRange.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepOverRange.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepOverRange.cpp Thu May 10 11:19:22 2012
@@ -95,7 +95,7 @@
// in a trampoline we think the frame is older because the trampoline confused the backtracer.
// As below, we step through first, and then try to figure out how to get back out again.
- new_plan = m_thread.QueueThreadPlanForStepThrough (false, stop_others);
+ new_plan = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
if (new_plan != NULL && log)
log->Printf("Thought I stepped out, but in fact arrived at a trampoline.");
@@ -122,7 +122,7 @@
}
else
{
- new_plan = m_thread.QueueThreadPlanForStepThrough (false, stop_others);
+ new_plan = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
}
}
@@ -143,7 +143,7 @@
// in which case we need to get out of there. But if we are in a stub then it's
// likely going to be hard to get out from here. It is probably easiest to step into the
// stub, and then it will be straight-forward to step out.
- new_plan = m_thread.QueueThreadPlanForStepThrough (false, stop_others);
+ new_plan = m_thread.QueueThreadPlanForStepThrough (m_stack_id, false, stop_others);
}
}
Modified: lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepThrough.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepThrough.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepThrough.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/ThreadPlanStepThrough.cpp Thu May 10 11:19:22 2012
@@ -32,11 +32,12 @@
// FIXME: At present only handles DYLD trampolines.
//----------------------------------------------------------------------
-ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, bool stop_others) :
+ThreadPlanStepThrough::ThreadPlanStepThrough (Thread &thread, StackID &m_stack_id, bool stop_others) :
ThreadPlan (ThreadPlan::eKindStepThrough, "Step through trampolines and prologues", thread, eVoteNoOpinion, eVoteNoOpinion),
m_start_address (0),
m_backstop_bkpt_id (LLDB_INVALID_BREAK_ID),
m_backstop_addr(LLDB_INVALID_ADDRESS),
+ m_return_stack_id (m_stack_id),
m_stop_others (stop_others)
{
@@ -46,12 +47,11 @@
if (m_sub_plan_sp)
{
m_start_address = GetThread().GetRegisterContext()->GetPC(0);
- m_stack_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
// We are going to return back to the concrete frame 1, we might pass by some inlined code that we're in
// the middle of by doing this, but it's easier than trying to figure out where the inlined code might return to.
- StackFrameSP return_frame_sp (m_thread.GetFrameWithConcreteFrameIndex(1));
+ StackFrameSP return_frame_sp = m_thread.GetFrameWithStackID (m_stack_id);
if (return_frame_sp)
{
@@ -73,11 +73,7 @@
ThreadPlanStepThrough::~ThreadPlanStepThrough ()
{
- if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID)
- {
- m_thread.GetProcess()->GetTarget().RemoveBreakpointByID (m_backstop_bkpt_id);
- m_backstop_bkpt_id = LLDB_INVALID_BREAK_ID;
- }
+ ClearBackstopBreakpoint ();
}
void
@@ -161,6 +157,13 @@
if (IsPlanComplete())
return true;
+ // First, did we hit the backstop breakpoint?
+ if (HitOurBackstopBreakpoint())
+ {
+ SetPlanComplete(false);
+ return true;
+ }
+
// If we don't have a sub-plan, then we're also done (can't see how we would ever get here
// without a plan, but just in case.
@@ -170,20 +173,27 @@
return true;
}
- // First, did we hit the backstop breakpoint?
- if (HitOurBackstopBreakpoint())
- {
- SetPlanComplete();
- return true;
- }
-
-
// If the current sub plan is not done, we don't want to stop. Actually, we probably won't
// ever get here in this state, since we generally won't get asked any questions if out
// current sub-plan is not done...
if (!m_sub_plan_sp->IsPlanComplete())
+ return false;
+
+ // If our current sub plan failed, then let's just run to our backstop. If we can't do that then just stop.
+ if (!m_sub_plan_sp->PlanSucceeded())
+ {
+ if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID)
+ {
+ m_sub_plan_sp.reset();
return false;
-
+ }
+ else
+ {
+ SetPlanComplete(false);
+ return true;
+ }
+ }
+
// Next see if there is a specific step through plan at our current pc (these might
// chain, for instance stepping through a dylib trampoline to the objc dispatch function...)
LookForPlanToStepThroughFromCurrentPC();
@@ -208,7 +218,7 @@
StateType
ThreadPlanStepThrough::GetPlanRunState ()
{
- return eStateStepping;
+ return eStateRunning;
}
bool
@@ -224,14 +234,21 @@
return true;
}
+void
+ThreadPlanStepThrough::ClearBackstopBreakpoint ()
+{
+ if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID)
+ {
+ m_thread.GetProcess()->GetTarget().RemoveBreakpointByID (m_backstop_bkpt_id);
+ m_backstop_bkpt_id = LLDB_INVALID_BREAK_ID;
+ }
+}
+
bool
ThreadPlanStepThrough::MischiefManaged ()
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
- // ShouldStop will call HappyToStopHere, which will set the plan to complete if
- // we're done. So we can just check that here.
-
if (!IsPlanComplete())
{
return false;
@@ -240,12 +257,9 @@
{
if (log)
log->Printf("Completed step through step plan.");
+
+ ClearBackstopBreakpoint ();
ThreadPlan::MischiefManaged ();
- if (m_backstop_bkpt_id != LLDB_INVALID_BREAK_ID)
- {
- m_thread.GetProcess()->GetTarget().RemoveBreakpointByID (m_backstop_bkpt_id);
- m_backstop_bkpt_id = LLDB_INVALID_BREAK_ID;
- }
return true;
}
}
@@ -262,7 +276,7 @@
{
StackID cur_frame_zero_id = m_thread.GetStackFrameAtIndex(0)->GetStackID();
- if (cur_frame_zero_id == m_stack_id)
+ if (cur_frame_zero_id == m_return_stack_id)
{
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_STEP));
if (log)
Modified: lldb/branches/apple/python-GIL/source/Target/ThreadPlanTracer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/source/Target/ThreadPlanTracer.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/source/Target/ThreadPlanTracer.cpp (original)
+++ lldb/branches/apple/python-GIL/source/Target/ThreadPlanTracer.cpp Thu May 10 11:19:22 2012
@@ -219,8 +219,7 @@
max_opcode_byte_size,
show_address,
show_bytes,
- NULL,
- true);
+ NULL);
}
}
}
Modified: lldb/branches/apple/python-GIL/test/lang/objc/objc-stepping/TestObjCStepping.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/test/lang/objc/objc-stepping/TestObjCStepping.py?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/test/lang/objc/objc-stepping/TestObjCStepping.py (original)
+++ lldb/branches/apple/python-GIL/test/lang/objc/objc-stepping/TestObjCStepping.py Thu May 10 11:19:22 2012
@@ -34,6 +34,7 @@
self.sourceBase_randomMethod_line = line_number (self.main_source, '// SourceBase randomMethod start line.')
self.source_returnsStruct_start_line = line_number (self.main_source, '// Source returnsStruct start line.')
self.sourceBase_returnsStruct_start_line = line_number (self.main_source, '// SourceBase returnsStruct start line.')
+ self.stepped_past_nil_line = line_number (self.main_source, '// Step over nil should stop here.')
def objc_stepping(self):
"""Use Python APIs to test stepping into ObjC methods."""
@@ -43,23 +44,35 @@
self.assertTrue(target, VALID_TARGET)
self.main_source_spec = lldb.SBFileSpec (self.main_source)
+
+ breakpoints_to_disable = []
+
break1 = target.BreakpointCreateBySourceRegex ("// Set first breakpoint here.", self.main_source_spec)
self.assertTrue(break1, VALID_BREAKPOINT)
+ breakpoints_to_disable.append (break1)
break2 = target.BreakpointCreateBySourceRegex ("// Set second breakpoint here.", self.main_source_spec)
self.assertTrue(break2, VALID_BREAKPOINT)
+ breakpoints_to_disable.append (break2)
break3 = target.BreakpointCreateBySourceRegex ('// Set third breakpoint here.', self.main_source_spec)
self.assertTrue(break3, VALID_BREAKPOINT)
+ breakpoints_to_disable.append (break3)
break4 = target.BreakpointCreateBySourceRegex ('// Set fourth breakpoint here.', self.main_source_spec)
self.assertTrue(break4, VALID_BREAKPOINT)
+ breakpoints_to_disable.append (break4)
break5 = target.BreakpointCreateBySourceRegex ('// Set fifth breakpoint here.', self.main_source_spec)
self.assertTrue(break5, VALID_BREAKPOINT)
+ breakpoints_to_disable.append (break5)
break_returnStruct_call_super = target.BreakpointCreateBySourceRegex ('// Source returnsStruct call line.', self.main_source_spec)
self.assertTrue(break_returnStruct_call_super, VALID_BREAKPOINT)
+ breakpoints_to_disable.append (break_returnStruct_call_super)
+
+ break_step_nil = target.BreakpointCreateBySourceRegex ('// Set nil step breakpoint here.', self.main_source_spec)
+ self.assertTrue(break_step_nil, VALID_BREAKPOINT)
# Now launch the process, and do not stop at entry point.
process = target.LaunchSimple (None, None, os.getcwd())
@@ -155,6 +168,15 @@
line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
self.assertTrue (line_number == self.sourceBase_returnsStruct_start_line, "Stepped through super into SourceBase returnsStruct in swizzled object.")
+ for bkpt in breakpoints_to_disable:
+ bkpt.SetEnabled(False)
+
+ threads = lldbutil.continue_to_breakpoint (process, break_step_nil)
+ self.assertTrue (len(threads) == 1, "Continued to step nil breakpoint.")
+
+ thread.StepInto()
+ line_number = thread.GetFrameAtIndex(0).GetLineEntry().GetLine()
+ self.assertTrue (line_number == self.stepped_past_nil_line, "Step in over dispatch to nil stepped over.")
if __name__ == '__main__':
import atexit
Modified: lldb/branches/apple/python-GIL/test/lang/objc/objc-stepping/stepping-tests.m
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/test/lang/objc/objc-stepping/stepping-tests.m?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/test/lang/objc/objc-stepping/stepping-tests.m (original)
+++ lldb/branches/apple/python-GIL/test/lang/objc/objc-stepping/stepping-tests.m Thu May 10 11:19:22 2012
@@ -127,7 +127,12 @@
ret_val = [mySource returnsStruct]; // Set fourth breakpoint here.
[mySource setProperty: 5]; // Set fifth breakpoint here.
- [pool release];
+ // We also had a bug where stepping into a method dispatch to nil turned
+ // into continue. So make sure that works here:
+
+ mySource = nil;
+ [mySource randomMethod]; // Set nil step breakpoint here.
+ [pool release]; // Step over nil should stop here.
return 0;
}
Modified: lldb/branches/apple/python-GIL/test/redo.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/test/redo.py?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/test/redo.py (original)
+++ lldb/branches/apple/python-GIL/test/redo.py Thu May 10 11:19:22 2012
@@ -132,7 +132,7 @@
# End of option processing.
break
- if sys.argv[index].startswith('-F'):
+ if sys.argv[index] == '-F':
# Increment by 1 to fetch the filename component spec.
index += 1
if index >= len(sys.argv) or sys.argv[index].startswith('-'):
Modified: lldb/branches/apple/python-GIL/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/tools/driver/Driver.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/tools/driver/Driver.cpp (original)
+++ lldb/branches/apple/python-GIL/tools/driver/Driver.cpp Thu May 10 11:19:22 2012
@@ -1081,6 +1081,8 @@
if (driver->m_io_channel_ap.get() != NULL)
{
driver->m_io_channel_ap->OutWrite ("^C\n", 3, NO_ASYNC);
+ // I wish I could erase the entire input line, but there's no public API for that.
+ driver->m_io_channel_ap->EraseCharsBeforeCursor();
driver->m_io_channel_ap->RefreshPrompt();
}
break;
Modified: lldb/branches/apple/python-GIL/tools/driver/IOChannel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/tools/driver/IOChannel.cpp?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/tools/driver/IOChannel.cpp (original)
+++ lldb/branches/apple/python-GIL/tools/driver/IOChannel.cpp Thu May 10 11:19:22 2012
@@ -50,6 +50,13 @@
return pos->second.c_str();
}
+void
+IOChannel::EraseCharsBeforeCursor ()
+{
+ const LineInfo *line_info = el_line(m_edit_line);
+ el_deletestr(m_edit_line, line_info->cursor - line_info->buffer);
+}
+
unsigned char
IOChannel::ElCompletionFn (EditLine *e, int ch)
{
Modified: lldb/branches/apple/python-GIL/tools/driver/IOChannel.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/apple/python-GIL/tools/driver/IOChannel.h?rev=156549&r1=156548&r2=156549&view=diff
==============================================================================
--- lldb/branches/apple/python-GIL/tools/driver/IOChannel.h (original)
+++ lldb/branches/apple/python-GIL/tools/driver/IOChannel.h Thu May 10 11:19:22 2012
@@ -96,6 +96,9 @@
const char *
GetPrompt ();
+ void
+ EraseCharsBeforeCursor ();
+
static unsigned char
ElCompletionFn (EditLine *e, int ch);
More information about the lldb-commits
mailing list