From: s88 <dave.tw@gmail.com>
To: gdb@sourceware.org
Subject: gdb breakpoint on x86
Date: Mon, 16 Oct 2006 00:12:00 -0000 [thread overview]
Message-ID: <c9d32f760610151712q68421d60lc190b5d8633eba63@mail.gmail.com> (raw)
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
next reply other threads:[~2006-10-16 0:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-16 0:12 s88 [this message]
2006-10-16 0:39 ` Daniel Jacobowitz
2006-10-16 1:15 ` s88
2006-10-16 8:51 ` Frederic RISS
2006-10-16 14:42 ` Jean-Marc Saffroy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c9d32f760610151712q68421d60lc190b5d8633eba63@mail.gmail.com \
--to=dave.tw@gmail.com \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox