From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30763 invoked by alias); 16 Oct 2006 00:12:35 -0000 Received: (qmail 30749 invoked by uid 22791); 16 Oct 2006 00:12:35 -0000 X-Spam-Check-By: sourceware.org Received: from ug-out-1314.google.com (HELO ug-out-1314.google.com) (66.249.92.173) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 16 Oct 2006 00:12:32 +0000 Received: by ug-out-1314.google.com with SMTP id z36so670472uge for ; Sun, 15 Oct 2006 17:12:30 -0700 (PDT) Received: by 10.67.24.13 with SMTP id b13mr7340161ugj; Sun, 15 Oct 2006 17:12:29 -0700 (PDT) Received: by 10.67.99.11 with HTTP; Sun, 15 Oct 2006 17:12:29 -0700 (PDT) Message-ID: Date: Mon, 16 Oct 2006 00:12:00 -0000 From: s88 To: gdb@sourceware.org Subject: gdb breakpoint on x86 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-10/txt/msg00105.txt.bz2 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 #include 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