#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <ctype.h>
#include <unistd.h>
#include "dbg_msg.h"
#include "jt_arm.h"
#include "jt_cortex.h"
#include "jt_flash.h"
#include "jt_mmu.h"
#include "arm_gdbstub.h"
#include "arm_memory_mmap.h"
#include "arm_gdbstub_break.h"
int InsertBreakpoint | ( | uint32_t | addr, | |
int | len, | |||
int | watchORbreak | |||
) |
support function to insert a new Addr to the Breakpoint List
Since ICE-RT supports only two watchpoints we can have one of the three solutions: 2 HWBkpt and nither SWBkpt nor Watch alternative 2 Watch and nither HWBkpt nor SWBkpt alternative unlimited SWBkpt and either one HWBkpt or one SWBkpt
watchORbreak | tells us if it is a watchpoint (=1) or a breakpoint (=0) | |
len | tells us if it is an ARM (=4) or a Thumb (=2) instruction to break on | |
addr | is the addess to break on |
0 | on success | |
1 | on Failure | |
-1 | if requeset not supported |
References breakpointEntry::access, SymbolInfo::addr, allocateGdbSprintfBuf(), memMap::baseAddr, bit_test, breakpointContainer::bl_return_address, breakpointContainer::bl_return_len, SymbolInfo::breakIsActive, CB_ACTION_NON, DBG_LEVEL_GDB_ARM_INFO, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), DONT_HAVE_BL_RETURN, error_exit_code, findMemMapOfAddr(), breakpointContainer::firstHWBkptEntry, breakpointContainer::firstSWBkptEntry, breakpointContainer::firstWatchEntry, breakpointContainer::force_hardware_breakpoint, gdbPrintf(), memMap::MemBuffer::HalfWord, breakpointContainer::have_possible_bl_return_address, IF_DBG, breakpointEntry::instr, jtag_arm_mmu_virt2phys(), jtag_arm_ReadHalfword(), jtag_arm_ReadWord(), jtag_cortex_dwt_get_maxWatchpoints(), jtag_cortex_fpb_get_maxBreakpoints(), breakpointEntry::len, MAYBE_BL_RETURN, memMap::memBuffer, memMap::memBufferType, MMAP_T_APPLICATION_FLASH, MMAP_T_FLASH, MMAP_T_RAM, MMAP_T_REREAD_ROM, MMAP_T_ROM, breakpointEntry::nextBkptEntry, breakpointContainer::numberOfHWBkptEntrys, breakpointContainer::numberOfSWBkptEntrys, breakpointContainer::numberOfWatchEntrys, breakpointEntry::phys_addr, memMap::MemBufferType::Ram, RAM_PAGE_SIZE, RCMDPKTSIZE, memMap::MemBufferType::Ram::readPageBitmap, SymbolInfo::state, SYM_PRESENT, symbolMain, memMap::type, VALID_BL_RETURN, breakpointEntry::virt_addr, memMap::MemBuffer::Word, and memMap::MemBufferType::Ram::writeByteBitmap.
Referenced by checkActionNext(), and gdb_handle_exception().
int RemoveBreakpoint | ( | uint32_t | addr, | |
int | len, | |||
int | watchORbreak | |||
) |
support function to remove a watch or breakpoint if it is on its List If a SW Break will be removed, its original instruction will be also restored back to RAM
watchORbreak | tells us if it is a watchpoint (=1) or a breakpoint (=0) | |
len | tells ARM (=4) or Thumb (=2) - still ignored | |
addr | is the addess of the watch or break |
References breakpointContainer::bl_return_address, DBG_LEVEL_GDB_ARM_INFO, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), DONT_HAVE_BL_RETURN, DONT_HAVE_BL_UNDO, breakpointContainer::firstHWBkptEntry, breakpointContainer::firstSWBkptEntry, breakpointContainer::firstWatchEntry, gdb_write_mem(), breakpointContainer::have_bl_undo_address, breakpointContainer::have_possible_bl_return_address, breakpointEntry::instr, breakpointEntry::len, breakpointEntry::nextBkptEntry, breakpointContainer::numberOfHWBkptEntrys, breakpointContainer::numberOfSWBkptEntrys, breakpointContainer::numberOfWatchEntrys, breakpointEntry::phys_addr, VALID_BL_RETURN, and breakpointEntry::virt_addr.
Referenced by gdb_handle_exception(), gdb_main_loop(), and gdb_monitor_Rcmd().
int RemoveAllBreakpoints | ( | void | ) |
remove all breakpoints from (global) breakpointList
References DBG_LEVEL_GDB_ARM_INFO, dbgPrintf(), DONT_HAVE_BL_RETURN, DONT_HAVE_BL_UNDO, breakpointContainer::firstHWBkptEntry, breakpointContainer::firstSWBkptEntry, breakpointContainer::firstWatchEntry, gdb_write_mem(), gdb_writeback_Ram(), breakpointContainer::have_bl_undo_address, breakpointContainer::have_possible_bl_return_address, breakpointEntry::instr, breakpointEntry::len, breakpointEntry::nextBkptEntry, breakpointContainer::numberOfHWBkptEntrys, breakpointContainer::numberOfSWBkptEntrys, breakpointContainer::numberOfWatchEntrys, and breakpointEntry::phys_addr.
Referenced by gdb_main_loop().
int isBreakpointListEmpty | ( | void | ) |
check if (global) breakpointList is empty
1 | if empty | |
0 | if not empty |
References DONT_HAVE_BL_RETURN, breakpointContainer::have_possible_bl_return_address, breakpointContainer::numberOfHWBkptEntrys, breakpointContainer::numberOfSWBkptEntrys, and breakpointContainer::numberOfWatchEntrys.
Referenced by gdb_handle_exception().
int isAddrOnBreakpointList | ( | uint32_t | addr | ) |
check if a given (virtual) address if already at the (global) breakpointList
addr | (virtual) address |
1 | yes addr is at breakpointList | |
0 | no addr not found |
References breakpointContainer::bl_return_address, breakpointContainer::firstHWBkptEntry, breakpointContainer::firstSWBkptEntry, breakpointContainer::have_possible_bl_return_address, breakpointEntry::len, breakpointEntry::nextBkptEntry, breakpointContainer::numberOfHWBkptEntrys, breakpointContainer::numberOfSWBkptEntrys, VALID_BL_RETURN, and breakpointEntry::virt_addr.
Referenced by gdb_action_continue(), gdb_action_step(), and gdb_main_loop().
int gdbSetupJtagTarget_Breakpoint | ( | void | ) |
write HW breakpoints and/or SW break-pattern into ICE_RT or FPB/DWT (via JTAG)
- |
References breakpointEntry::access, DBG_LEVEL_GDB_ARM_WARN, dbgPrintf(), breakpointContainer::firstHWBkptEntry, breakpointContainer::firstWatchEntry, jtag_arm_IceRT_PutHWBreakPoint0(), jtag_arm_IceRT_PutHWBreakPoint1(), jtag_arm_IceRT_PutSWBreakPoint0(), jtag_arm_IceRT_PutSWBreakPoint1(), jtag_arm_IceRT_PutWatchPoint0(), jtag_arm_IceRT_PutWatchPoint1(), jtag_cortex_dwt_PutWatchPoint(), jtag_cortex_fpb_PutHWBreakPoint(), breakpointEntry::len, breakpointEntry::nextBkptEntry, breakpointContainer::numberOfHWBkptEntrys, breakpointContainer::numberOfSWBkptEntrys, breakpointContainer::numberOfWatchEntrys, and breakpointEntry::virt_addr.
Referenced by gdb_action_continue().
int gdbWriteSoftwareBreakToRAM | ( | void | ) |
write SW break pattern of any SW-breakpoint into RAM
- |
References breakpointContainer::firstSWBkptEntry, gdb_write_mem(), gdb_writeback_Ram(), breakpointEntry::len, breakpointEntry::nextBkptEntry, breakpointContainer::numberOfHWBkptEntrys, breakpointContainer::numberOfSWBkptEntrys, and breakpointEntry::phys_addr.
Referenced by gdb_action_continue().
int checkActionNext | ( | void | ) |
support function to check if we have seen a special breakpoint of the GDB "next" instruction. If so, and if we are still having free breakpoint resources; Insert this breakpoint, now. If there are not enouth resources; Return True, to emulte this by doing a lot of Step intruction.
- |
1 | try emulateing NEXT by doing autoStep | |
0 | do not emulate NEXT |
References allocateGdbSprintfBuf(), breakpointContainer::bl_return_address, breakpointContainer::bl_return_len, BUFMAX, CB_ACTION_NON, DBG_LEVEL_GDB_ARM_INFO, dbgPrintf(), DONT_HAVE_BL_RETURN, DONT_HAVE_BL_UNDO, gdbPrintf(), breakpointContainer::have_bl_undo_address, breakpointContainer::have_possible_bl_return_address, InsertBreakpoint(), jtag_cortex_fpb_get_maxBreakpoints(), breakpointContainer::numberOfHWBkptEntrys, breakpointContainer::numberOfSWBkptEntrys, breakpointContainer::numberOfWatchEntrys, and VALID_BL_RETURN.
Referenced by gdb_action_continue().
void preparePossibleActionNext | ( | uint32_t | return_addr, | |
uint32_t | undo_addr, | |||
enum HaveBlUndoAddr | undo_is_valid | |||
) |
if we have seen a valid ARM (or Thumb) branch and link instruction add it (for a possible GDB "next") if this "next" will be issued after a "step" add the address of the bl itself, too (so we can do an undo if setting breakpoints fails) also we keep the Mode of the "step" in mind, as undo_is_valid == 1 was ARM undo_is_valid == 2 was THUMB
return_addr | ||
undo_addr | ||
undo_is_valid |
References breakpointContainer::allow_auto_step, breakpointContainer::bl_return_address, breakpointContainer::bl_undo_address, DONT_HAVE_BL_RETURN, DONT_HAVE_BL_UNDO, breakpointContainer::have_bl_undo_address, breakpointContainer::have_possible_bl_return_address, MAYBE_BL_RETURN, and VALID_BL_RETURN.
Referenced by gdb_action_step(), and gdb_handle_exception().
void cancelActionNext | ( | void | ) |
if not currently having a breakpoint used by active AutoStep delete the old (and now known to be wrong) return addess
- |
References DONT_HAVE_BL_RETURN, DONT_HAVE_BL_UNDO, breakpointContainer::have_bl_undo_address, breakpointContainer::have_possible_bl_return_address, and VALID_BL_RETURN.
Referenced by gdb_action_step().
void undoAfterBlStep | ( | struct reg_set * | raw_regs | ) |
perform an undo after an branch and link instruction (if no step has been taken PC is still equal to bl_undo_address and nothing is realy changed)
raw_regs | set of all currend CPU reisters |
References CAN_BL_UNDO_ARM, CAN_BL_UNDO_THUMB, reg_set::CPSR, DONT_HAVE_BL_UNDO, breakpointContainer::have_bl_undo_address, breakpointContainer::have_possible_bl_return_address, reg_set::Regs::r, reg_set::regs, and VALID_BL_RETURN.
Referenced by gdb_main_loop().
Referenced by gdb_handle_exception(), gdb_monitor_Rcmd(), gdbLookupArmInstr(), and gdbLookupThumbInstr().