Index: source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp =================================================================== --- source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -21,6 +21,7 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Core/Error.h" #include "lldb/Core/Debugger.h" @@ -329,12 +330,32 @@ default: assert(false && "Unhandled architecture in PlatformFreeBSD::GetSoftwareBreakpointTrapOpcode()"); break; - case llvm::Triple::x86: - case llvm::Triple::x86_64: + case llvm::Triple::arm: { - static const uint8_t g_i386_opcode[] = { 0xCC }; - trap_opcode = g_i386_opcode; - trap_opcode_size = sizeof(g_i386_opcode); + static const uint8_t g_arm_opcode[] = { 0xfe, 0xde, 0xff, 0xe7 }; + static const uint8_t g_thumb_opcode[] = { 0x01, 0xde }; + bool is_thumb = false; + lldb::BreakpointLocationSP bp_loc_sp = bp_site->GetOwnerAtIndex (0); + if (bp_loc_sp) + { + Address addr = bp_loc_sp->GetAddress(); + AddressClass addr_class = addr.GetAddressClass (); + if ((addr_class == eAddressClassCodeAlternateISA) + || (addr_class == eAddressClassUnknown && (bp_site->GetLoadAddress() & 1))) + is_thumb = true; + } + if (is_thumb) + { + // TODO : Enable when FreeBSD supports thumb breakpoints + // FreeBSD kernel as of 10.x, does not support thumb breakpoints + trap_opcode = g_thumb_opcode; + trap_opcode_size = 0; + } + else + { + trap_opcode = g_arm_opcode; + trap_opcode_size = sizeof(g_arm_opcode); + } } break; case llvm::Triple::ppc: @@ -344,6 +365,15 @@ trap_opcode = g_ppc_opcode; trap_opcode_size = sizeof(g_ppc_opcode); } + break; + case llvm::Triple::x86: + case llvm::Triple::x86_64: + { + static const uint8_t g_i386_opcode[] = { 0xCC }; + trap_opcode = g_i386_opcode; + trap_opcode_size = sizeof(g_i386_opcode); + } + break; } if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size)) Index: source/Plugins/Process/POSIX/POSIXThread.cpp =================================================================== --- source/Plugins/Process/POSIX/POSIXThread.cpp +++ source/Plugins/Process/POSIX/POSIXThread.cpp @@ -41,6 +41,7 @@ #include "Plugins/Process/Utility/RegisterContextLinux_arm64.h" #include "Plugins/Process/Utility/RegisterContextLinux_i386.h" #include "Plugins/Process/Utility/RegisterContextLinux_x86_64.h" +#include "Plugins/Process/Utility/RegisterContextFreeBSD_arm.h" #include "Plugins/Process/Utility/RegisterContextFreeBSD_i386.h" #include "Plugins/Process/Utility/RegisterContextFreeBSD_mips64.h" #include "Plugins/Process/Utility/RegisterContextFreeBSD_powerpc.h" @@ -171,7 +172,11 @@ case llvm::Triple::FreeBSD: switch (target_arch.GetMachine()) { - case llvm::Triple::ppc: + case llvm::Triple::arm: + reg_interface = new RegisterContextFreeBSD_arm(target_arch); + break; + + case llvm::Triple::ppc: #ifndef __powerpc64__ reg_interface = new RegisterContextFreeBSD_powerpc32(target_arch); break;