From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26576 invoked by alias); 8 Aug 2013 08:44:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26559 invoked by uid 89); 8 Aug 2013 08:44:19 -0000 X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL,BAYES_50,MSGID_MULTIPLE_AT,RDNS_NONE autolearn=no version=3.3.1 Received: from Unknown (HELO mailhost.u-strasbg.fr) (130.79.201.42) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 08 Aug 2013 08:44:19 +0000 Received: from md15.u-strasbg.fr (md15.u-strasbg.fr [130.79.200.204]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r788i9FO022098 for ; Thu, 8 Aug 2013 10:44:09 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from ms12.u-strasbg.fr (ms12.u-strasbg.fr [130.79.204.112]) by md15.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id r788i991016796 for ; Thu, 8 Aug 2013 10:44:09 +0200 (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (Authenticated sender: mullerp) by ms12.u-strasbg.fr (Postfix) with ESMTPSA id C80491FD92 for ; Thu, 8 Aug 2013 10:44:09 +0200 (CEST) From: "Pierre Muller" To: Subject: [RFC] Add new commands to windows native code. Date: Thu, 08 Aug 2013 08:44:00 -0000 Message-ID: <001f01ce9413$72450b20$56cf2160$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-SW-Source: 2013-08/txt/msg00236.txt.bz2 This patch adds three new commands to windows native code: these are three Boolean set/show commands : 1) set print-first-chance-exception on/off to also print a "gdb: unknown target exception ..." string on each first-chance exception. 2) set stop-on-first-chance-exception on/off to stop code execution each time a first chance exception occurs. and 3) set stop-on-debug-string-event on/off to stop code execution each time a debug string event occurs. The third command was particularly useful to understand and eliminate a msvcrt debug string event generated by GDB code (fix to be submitted in a next patch). Comments most welcome, Pierre Muller GDB pascal language maintainer 2013-08-07 Pierre Muller * src/gdb/windows-nat.c (print_first_chance_exception): New static variable. (stop_on_first_chance_exception): New static variable. (stop_on_debug_string_event): New static variable. (handle_output_debug_string): Stop on warning if STOP_ON_DEBUG_STRING_EVENT is non zero. (handle_exception): Print first chance exception if PRINT_FIRST_CHANCE_EXCEPTION is non zero. Stop on first chance exception if STOP_ON_FIRST_CHANCE_EXCEPTION is non zero. (_initialize_windows_nat): Register set/show commands for the three new variables introduced above. Index: src/gdb/windows-nat.c =================================================================== RCS file: /cvs/src/src/gdb/windows-nat.c,v retrieving revision 1.257 diff -u -p -r1.257 windows-nat.c --- src/gdb/windows-nat.c 1 Jul 2013 11:28:30 -0000 1.257 +++ src/gdb/windows-nat.c 7 Aug 2013 12:37:33 -0000 @@ -222,6 +222,13 @@ static int debug_events = 0; /* show ev static int debug_memory = 0; /* show target memory accesses */ static int debug_exceptions = 0; /* show target exceptions */ static int useshell = 0; /* use shell for subprocesses */ +/* Show first chance exceptions. */ +static int print_first_chance_exception = 0; +/* Stop on first chance exceptions. */ +static int stop_on_first_chance_exception = 0; +/* Stop on debug string event. */ +static int stop_on_debug_string_event = 0; + /* This vector maps GDB's idea of a register's number into an offset in the windows exception context vector. @@ -958,7 +965,15 @@ handle_output_debug_string (struct targe #ifdef __CYGWIN__ if (strncmp (s, "cYg", 3) != 0) #endif - warning (("%s"), s); + { + warning (("%s"), s); + if (stop_on_debug_string_event) + { + retval = current_event.dwThreadId; + ourstatus->kind = TARGET_WAITKIND_STOPPED; + } + + } } #ifdef __COPY_CONTEXT_SIZE else @@ -1234,7 +1249,20 @@ handle_exception (struct target_waitstat default: /* Treat unhandled first chance exceptions specially. */ if (current_event.u.Exception.dwFirstChance) - return -1; + { + if (print_first_chance_exception) + printf_unfiltered ("gdb: unknown target exception 0x%08x at %s\n", + (unsigned) current_event.u.Exception.ExceptionRecord.ExceptionCode, + host_address_to_string ( + current_event.u.Exception.ExceptionRecord.ExceptionAddress)); + + if (stop_on_first_chance_exception) + { + ourstatus->value.sig = GDB_SIGNAL_UNKNOWN; + break; + } + return -1; + } printf_unfiltered ("gdb: unknown target exception 0x%08x at %s\n", (unsigned) current_event.u.Exception.ExceptionRecord.ExceptionCode, host_address_to_string ( @@ -2635,6 +2664,30 @@ Show whether to display kernel exception NULL, /* FIXME: i18n: */ &setlist, &showlist); + add_setshow_boolean_cmd ("print-first-chance-exception", class_support, + &print_first_chance_exception, _("\ +Set whether to display first chance exceptions in child process."), _("\ +Show whether to display first chance exceptions in child process."), NULL, + NULL, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); + + add_setshow_boolean_cmd ("stop-on-first-chance-exception", class_support, + &stop_on_first_chance_exception, _("\ +Set whether to stop on first chance exceptions in child process."), _("\ +Show whether to stop on first chance exceptions in child process."), NULL, + NULL, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); + + add_setshow_boolean_cmd ("stop-on-debug-string-event", class_support, + &stop_on_debug_string_event, _("\ +Set whether to stop on debug string event in child process."), _("\ +Show whether to stop on debug string event in child process."), NULL, + NULL, + NULL, /* FIXME: i18n: */ + &setlist, &showlist); + init_w32_command_list (); add_cmd ("selector", class_info, display_selectors,