From 2586e94bfb778b3b306c6cc66e179012cfbdbb2e Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Tue, 28 Oct 2014 03:43:54 +0000 Subject: [PATCH] Add breakpoint instruction byte sequences for arm to PlatformLinux::GetSoftwareBreakpointTrapOpcode. Patch by Stephane Sezer. http://reviews.llvm.org/D5923 llvm-svn: 220762 --- .../Plugins/Platform/Linux/PlatformLinux.cpp | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index d158e27..7dc0a20 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -21,6 +21,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Error.h" #include "lldb/Core/Log.h" @@ -534,6 +535,33 @@ PlatformLinux::GetSoftwareBreakpointTrapOpcode (Target &target, trap_opcode_size = sizeof(g_hex_opcode); } break; + case llvm::Triple::arm: + { + // The ARM reference recommends the use of 0xe7fddefe and 0xdefe + // but the linux kernel does otherwise. + static const uint8_t g_arm_breakpoint_opcode[] = { 0xf0, 0x01, 0xf0, 0xe7 }; + static const uint8_t g_thumb_breakpoint_opcode[] = { 0x01, 0xde }; + + lldb::BreakpointLocationSP bp_loc_sp (bp_site->GetOwnerAtIndex (0)); + AddressClass addr_class = eAddressClassUnknown; + + if (bp_loc_sp) + addr_class = bp_loc_sp->GetAddress ().GetAddressClass (); + + if (addr_class == eAddressClassCodeAlternateISA + || (addr_class == eAddressClassUnknown + && bp_loc_sp->GetAddress().GetOffset() & 1)) + { + trap_opcode = g_thumb_breakpoint_opcode; + trap_opcode_size = sizeof(g_thumb_breakpoint_opcode); + } + else + { + trap_opcode = g_arm_breakpoint_opcode; + trap_opcode_size = sizeof(g_arm_breakpoint_opcode); + } + } + break; } if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size)) -- 2.7.4