This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gdb breakpoint on x86


Hi all:
I'm trying to build  up a simple breakpoint insertor by myself. I also
tracing the gdb source code and reference it!!!
But I feel confused about the int 3(0xcc), the function
"i386_breakpoint_from_pc" has 2 parameters, one of the parameter is a
program counter. I'm not sure the meaning of this program counter.
Does this program counter perform an ISR? Once the 0xcc trig, the
current program counter will replace by this one?

By the way, the following code can compile without any error. But the
sizeof which in the "i386_breakpoint_from_pc"  derives segmentation
fault.

Could anyone help me?!
Thanks.

#include <stdlib.h>
#include <stdio.h>

typedef int (*_test) (int, int);

typedef unsigned char my_byte;
typedef unsigned long CORE_ADDR;

static const my_byte *i386_breakpoint_from_pc (CORE_ADDR * pc, int *len);


/** * My test function */ int my_test (int a, int b){ int i; int ret; for (i = 0; i < a; i++) { ret = a + 1 << b; } return ret; }

void test (_test t){
int *len=0;
my_byte *b=NULL;
printf("len = %d",len);
b = (my_byte *)i386_breakpoint_from_pc ((CORE_ADDR *)(t), len);
printf("len = %d",len);
}

static const my_byte *i386_breakpoint_from_pc (CORE_ADDR * pc, int *len){
static my_byte break_insn[] = { 0xcc };       /* int 3 */
*len = sizeof (break_insn);
return break_insn;
}

int main (void){
test (my_test);
return 0;
}



--
System  on Chip Design  Lab.
Dept. of Computer Science and Information Engineering,
National Chung Cheng University
E-mail : s88.tw@acm.org


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]