From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10314 invoked by alias); 9 May 2005 19:44:20 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 10246 invoked from network); 9 May 2005 19:44:09 -0000 Received: from unknown (HELO mail.siemenscom.com) (12.146.131.10) by sourceware.org with SMTP; 9 May 2005 19:44:09 -0000 Received: from fdns2.rolm.com (localhost [127.0.0.1]) by mail.siemenscom.com (8.12.10/8.12.10) with ESMTP id j49JJM0O026402 for ; Mon, 9 May 2005 12:19:23 -0700 Received: from stca200a.bus.sc.rolm.com (stca200a.bus.sc.rolm.com [165.218.68.180]) by fdns2.rolm.com (8.12.10/8.12.10) with ESMTP id j49Ji75Z029963 for ; Mon, 9 May 2005 12:44:07 -0700 (PDT) Received: by stca200a.bus.sc.rolm.com with Internet Mail Service (5.5.2657.72) id ; Mon, 9 May 2005 12:44:06 -0700 Message-ID: <2DA8F872430BE8469BF0F403A6103F9205CFC9@stca20aa.bocc.icn.siemens.com> From: "Bloch, Jack" To: gdb@sources.redhat.com Subject: Reading target registers Date: Mon, 09 May 2005 19:44:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2005-05/txt/msg00119.txt.bz2 While this is not a direct GDB question, I'm hoping someone can answer me. I have an application which uses the ptrace interface to attach to a target process and read the target registers (I'm specifically interested in the EIP). It will run on a SuSE 2.6 Kernel x86 based machine. My code is below. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef BFD64 #define BFD64 #endif #include #include #include "tracer.h" int main (int p_argc, char **p_argv) { int l_ret; pid_t l_pid unsigned long l_regs[17]; /***********************************************************************/ /* i have ommitted the code which retrieves the command line arguments */ /***********************************************************************/ if ((l_ret = ptrace(PTRACE_ATTACH,l_pid,NULL,NULL)) < 0) { l_ret = errno; printf("ERROR %s ATTACHING TO TARGET !!!\n",strerror(l_ret); return(l_ret); } if ((l_ret = ptrace(PTRACE_GETREGS,l_pid,NULL,&l_regs)) < 0) { l_ret = errno; printf("ERROR %s READING TARGET REGISTERS !!!\n",strerror(l_ret); return(l_ret); } printf("CURRENT EIP 0x%x\n",l_regs[EIP]); return(l_ret); } The EIP value is always incorrect. Any ideas. Please CC me directly on any response. Regards, Jack