From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10237 invoked by alias); 12 Apr 2004 21:25:50 -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 9881 invoked from network); 12 Apr 2004 21:25:18 -0000 Received: from unknown (HELO reverberate.org) (207.207.127.56) by sources.redhat.com with SMTP; 12 Apr 2004 21:25:18 -0000 Received: from [207.207.116.45] (trimble1dhcp45.ups.edu [207.207.116.45]) by reverberate.org (Postfix) with ESMTP id 1151A27EC0 for ; Mon, 12 Apr 2004 22:52:40 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v613) Content-Transfer-Encoding: 7bit Message-Id: Content-Type: text/plain; charset=US-ASCII; format=flowed To: gdb@sources.redhat.com From: Joshua Haberman Subject: detecting gdb at runtime? Date: Mon, 12 Apr 2004 21:38:00 -0000 X-SW-Source: 2004-04/txt/msg00067.txt.bz2 Is there any way to detect GDB at runtime? I am currently experimenting with different ways to handle errors in a C++ library I am writing. I am using an Assert() macro to verify conditions throughout the program, much like C's assert() function. I believe that the best way to respond to a failed assertion is to throw an exception because it gives the client application a chance to recover as best it can. However, if the program is running in a debugger, throwing an exception is sub-optimal because it cannot give you a stack trace. My goal is to have my Assert() macro SIGTRAP if a debugger is running to break into the debugger, otherwise throw an exception. Is there any way to make this happen? (Please CC me, I am not subscribed). Josh Haberman