From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 819 invoked by alias); 24 Jan 2007 12:48:33 -0000 Received: (qmail 513 invoked by uid 22791); 24 Jan 2007 12:48:31 -0000 X-Spam-Check-By: sourceware.org Received: from nz-out-0506.google.com (HELO nz-out-0506.google.com) (64.233.162.235) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 24 Jan 2007 12:48:24 +0000 Received: by nz-out-0506.google.com with SMTP id m7so141586nzf for ; Wed, 24 Jan 2007 04:48:22 -0800 (PST) Received: by 10.65.241.20 with SMTP id t20mr1054073qbr.1169642902702; Wed, 24 Jan 2007 04:48:22 -0800 (PST) Received: from ?192.168.132.167? ( [222.66.14.54]) by mx.google.com with ESMTP id j4sm648254nzd.2007.01.24.04.48.20; Wed, 24 Jan 2007 04:48:21 -0800 (PST) Message-ID: <45B75585.2030900@gmail.com> Date: Wed, 24 Jan 2007 12:48:00 -0000 From: Bin Chen User-Agent: Thunderbird 1.5.0.8 (X11/20061116) MIME-Version: 1.0 To: gdb@sourceware.org Subject: attach gdbserver to itself Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00306.txt.bz2 Hi, Current I am doing a trick that attach the gdbserver to itself when the process encounter the segment fault, like this: void segv_handler(int no) { int pid, status; VoIPLog("segv_handler."); char buf[128]; pid = getpid(); sprintf(buf, "/usr/bin/gdbserver :9988 --attach %d", pid); pid = fork(); if (pid == 0) { system(buf); } else ::wait((int *)&status); return; } But in most of time this can't get useful information, especially in multi threading env, most of time the result is wrong, of course, I am saying the backtrace. But if I start program by gdbserver :9988 program, it can catch the error. What is the difference? How can I revise my code to make above code has same effect like starting the program by gdbserver? I am debugging in ARM platform. Any help appreciated! Bin Chen