Chinaunix首页 | 论坛 | 博客
  • 博客访问: 661691
  • 博文数量: 156
  • 博客积分: 4833
  • 博客等级: 上校
  • 技术积分: 1554
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-21 19:36
文章分类

全部博文(156)

文章存档

2016年(2)

2013年(1)

2012年(13)

2011年(30)

2010年(46)

2009年(29)

2008年(23)

2007年(12)

分类: LINUX

2011-12-02 17:52:54

 移植GDBzz.txt  

通过break指令替换现有指令
关键代码段:

GDB:
  
     //
     _initialize_mips_linux_nat->
     linux_trad_target->
     inf_ptrace_trad_target->
     inf_ptrace_target->
     inf_child_target->

     In fact Linux & BSD all call
     inf_ptrace_target->
     inf_child_target:
     to_insert_breakpoint = memory_insert_breakpoint
     //
     insert_single_step_breakpoint->
     deprecated_insert_raw_breakpoint->
     target_insert_breakpoint=memory_insert_breakpoint
     //
     handle_inferior_event->
     maybe_software_singlestep->
     gdbarch_software_single_step->
     mips_software_single_step
     //
     mips_software_single_step
     mips_insert_breakpoint
     //
     memory_insert_breakpoint =
     default_memory_insert_breakpoint
     mips_breakpoint_from_pc(what for insert)
  
     displaced_step_at_entry_point->
     gdbarch_breakpoint_from_pc:mips_breakpoint_from_pc

      //
      default_memory_insert_breakpoint->
      target_write_memory->target_write->
      target_write_with_progress->target_write_partial->
      target_xfer_partial->memory_xfer_partial
      Linux:
        linux_xfer_partial->linux_proc_xfer_partial :read (proc mem)
        inf_ptrace_xfer_partial (PTRACE_POKETEXT)
 
      BSD:
        inf_ptrace_xfer_partial (ptrace (PT_WRITE_I)  )

 
     /* The IDT board uses an unusual breakpoint value, and
        sometimes gets confused when it sees the usual MIPS
        breakpoint instruction.  */
       static gdb_byte big_breakpoint[] = { 0, 0x5, 0, 0xd };
       static gdb_byte pmon_big_breakpoint[] = { 0, 0, 0, 0xd };
       static gdb_byte idt_big_breakpoint[] = { 0, 0, 0x0a, 0xd };
       /* Likewise, IRIX appears to expect a different breakpoint,
          although this is not apparent until you try to use pthreads.  */
       static gdb_byte irix_big_breakpoint[] = { 0, 0, 0, 0xd };
      
   等待:
     
       Linux:
           _initialize_mips_linux_nat:linux_nat_add_target:linux_nat_wait
    
           linux_nat_stopped_by_watchpoint = mips_linux_stopped_by_watchpoint(是否由watchpoint触发)
           mips_linux_stopped_data_address          
          
       BSD:         
           _initialize_mipsnbsd_nat:inf_ptrace_target inf_ptrace_wait  waitpid
         
       ////////////////
    Low Level Get REGS: 
          
           mips_read_pc->regcache_cooked_read_signed->
           regcache_cooked_read->regcache_raw_read->target_fetch_registers->to_fetch_registers
       
           mips_print_registers_info
           mips_read_pc : mips64_linux_fetch_registers    ptrace  PTRACE_GETREGS
           mipsnbsd_fetch_inferior_registers              ptrace  PT_GETREGS       

Linux KERNEL:
     set_except_vector(9, handle_bp);
     handle_bp

     [arch/mips/kernel/genex.S]
     BUILD_HANDLER bp bp sti silent /* #9 */

      do_/handler = do_bp
        (kernel:  notify_die)
      do_trap_or_bp
        force_sig(SIGTRAP, current);
BSD Kernel:
      MipsKernGenException (exception.S):
             PTR_LA  gp, _C_LABEL(_gp)
             PTR_LA  k0, _C_LABEL(trap)
             jalr    k0
      -> register_t  trap(struct trapframe *trapframe):
      case T_BREAK + T_USER:
      ->trapsignal

阅读(1868) | 评论(0) | 转发(0) |
0

上一篇:Linux pci 老文档

下一篇:core dump

给主人留下些什么吧!~~