📄 dbgarchlib.c
字号:
/* dbgArchLib.c - i386/i486 architecture-specific debugging facilities *//* Copyright 1984-1997 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01g,08jan98,dbt modified for new breakpoint scheme01f,10feb95,jdi doc tweak for 5.2.01e,14dec93,hdn added _archHelp_msg.01d,29nov93,hdn added eax() - eflags().01c,27aug93,hdn added _dbgTaskPCSet().01b,16jun93,hdn updated to 5.1. - changed functions to ansi style - changed VOID to void - changed copyright notice01a,08jul92,hdn written based on tron/dbgLib.c.*//*DESCRIPTIONThis module provides the architecture dependent support functions fordbgLib. NOMANUAL*//* LINTLIBRARY */#include "vxWorks.h"#include "taskLib.h"#include "taskArchLib.h"#include "intLib.h"#include "regs.h"#include "iv.h"#include "cacheLib.h"#include "ioLib.h"#include "dsmLib.h"#include "vxLib.h"#include "usrLib.h"#include "stdio.h"#include "dbgLib.h"/* external variables */IMPORT int dsmInst ();/* global variable */char * _archHelp_msg = #ifdef DBG_HARDWARE_BP "bh addr[,access[,task[,count[,quiet]]]] Set hardware breakpoint\n" " access : 0 - instruction 1 - write 1 byte\n" " 3 - read/write 1 byte 5 - write 2 bytes\n" " 7 - read/write 2 bytes d - write 4 bytes\n" " f - read/write 4 bytes"#endif /* DBG_HARDWARE_BP */ "\n";/* defines */#define DSM(addr,inst,mask) ((*(addr) & (mask)) == (inst))/* forward declarations *//********************************************************************************* _dbgArchInit - architecture dependent initialization routine** This routine initialize global function pointers that are architecture * specific.** RETURNS: N/A** NOMANUAL*/void _dbgArchInit (void) { _dbgDsmInstRtn = (FUNCPTR) dsmInst; }/********************************************************************************* _dbgRetAdrsGet - get a next instruction for cret ()** if next instruction is a ENTER or RET, return address is on top of stack.* otherwise it follows saved frame pointer.*** NOMANUAL*/INSTR * _dbgRetAdrsGet ( REG_SET * pRegSet /* register set */ ) { INSTR *returnAddress; if (DSM(pRegSet->pc, PUSH_EBP, PUSH_EBP_MASK) && DSM(pRegSet->pc+1, MOV_ESP0, MOV_ESP0_MASK) && DSM(pRegSet->pc+2, MOV_ESP1, MOV_ESP1_MASK)) { returnAddress = *(INSTR **)pRegSet->spReg; } else if (DSM(pRegSet->pc-1, PUSH_EBP, PUSH_EBP_MASK) && DSM(pRegSet->pc, MOV_ESP0, MOV_ESP0_MASK) && DSM(pRegSet->pc+1, MOV_ESP1, MOV_ESP1_MASK)) { returnAddress = *((INSTR **)pRegSet->spReg + 1); } else if (DSM(pRegSet->pc, ENTER, ENTER_MASK)) { returnAddress = *(INSTR **)pRegSet->spReg; } else if ((DSM(pRegSet->pc, RET, RET_MASK)) || (DSM(pRegSet->pc, RETADD, RETADD_MASK))) { returnAddress = *(INSTR **)pRegSet->spReg; } else { returnAddress = *((INSTR **)pRegSet->fpReg + 1); } return (returnAddress); }/********************************************************************************* _dbgFuncCallCheck - check next instruction** This routine checks to see if the next instruction is a CALL* If it is, it returns TRUE, otherwise, returns FALSE.** RETURNS: TRUE if next instruction is a CALL, or FALSE otherwise.** NOMANUAL*/BOOL _dbgFuncCallCheck ( INSTR * addr /* pointer to instruction */ ) { return ((DSM (addr, CALL_INDIR0, CALL_INDIR0_MASK) && DSM (addr + 1, CALL_INDIR1, CALL_INDIR1_MASK)) || (DSM (addr, CALL_DIR, CALL_DIR_MASK))); }/********************************************************************************* _dbgInstSizeGet - set up breakpoint instruction** RETURNS: size of the instruction at specified location.** NOMANUAL*/int _dbgInstSizeGet ( INSTR * pBrkInst /* pointer to hold breakpoint instruction */ ) { return (dsmNbytes (pBrkInst)); }/********************************************************************************* _dbgTaskPCGet - get task's pc** RETURNS:task's program counter** NOMANUAL*/INSTR * _dbgTaskPCGet ( int tid /* task's id */ ) { REG_SET regSet; (void) taskRegsGet (tid, ®Set); return ((INSTR *) regSet.pc); }/********************************************************************************* _dbgTaskPCSet - set task's pc** RETURNS: N/A** NOMANUAL*/void _dbgTaskPCSet ( int task, /* task id */ INSTR * pc, /* new PC */ INSTR * npc /* not supported on I80X86 */ ) { REG_SET regSet; if (taskRegsGet (task, ®Set) != OK) return; regSet.pc = pc; (void)taskRegsSet (task, ®Set); }#ifdef DBG_HARDWARE_BP/********************************************************************************* _dbgBrkDisplayHard - print hardware breakpoint** This routine print hardware breakpoint.** NOMANUAL*/void _dbgBrkDisplayHard ( BRKPT * pBp /* breakpoint table entry */ ) { int type; if ((pBp->bp_flags & BRK_HARDWARE) == 0) return; type = pBp->bp_flags & BRK_HARDMASK; printf (" (hard-"); switch (type) { case BRK_INST: printf ("inst)"); break; case BRK_DATAW1: printf ("dataw1)"); break; case BRK_DATAW2: printf ("dataw2)"); break; case BRK_DATAW4: printf ("dataw4)"); break; case BRK_DATARW1: printf ("datarw1)"); break; case BRK_DATARW2: printf ("datarw2)"); break; case BRK_DATARW4: printf ("datarw4)"); break; default: printf ("unknown)"); break; } }#endif /* DBG_HARDWARE_BP */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -