From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5152 invoked by alias); 30 Jul 2011 22:20:57 -0000 Received: (qmail 5143 invoked by uid 22791); 30 Jul 2011 22:20:56 -0000 X-SWARE-Spam-Status: No, hits=-7.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 30 Jul 2011 22:20:41 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6UMKfno017298 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 30 Jul 2011 18:20:41 -0400 Received: from host1.jankratochvil.net (ovpn-116-16.ams2.redhat.com [10.36.116.16]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6UMKdrw009824 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 30 Jul 2011 18:20:41 -0400 Received: from host1.jankratochvil.net (localhost [127.0.0.1]) by host1.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p6UMKcoR026986 for ; Sun, 31 Jul 2011 00:20:38 +0200 Received: (from jkratoch@localhost) by host1.jankratochvil.net (8.14.4/8.14.4/Submit) id p6UMKcqp026985 for gdb-patches@sourceware.org; Sun, 31 Jul 2011 00:20:38 +0200 Date: Sun, 31 Jul 2011 01:03:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch 2/2] Mostly code cleanup: stack.c: TRY_CATCH simplifications Message-ID: <20110730222038.GB26756@host1.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2011-07/txt/msg00828.txt.bz2 Hi, after [patch 1/2] some constructs become obviously redundant. This is a "code cleanup" except for the RETURN_MASK_ALL change. I haven't found any specific reason in the mail thread introducing it and neither any reason in the current code, IMO it was only a mistake. No regressions on {x86_64,x86_64-m32,i686}-fedora16pre-linux-gnu. I will check it in in some time. Thanks, Jan gdb/ 2011-07-31 Jan Kratochvil * stack.c (do_gdb_disassembly): Use RETURN_MASK_ERROR, simplify the exception_print code path. (backtrace_command): Remove variable e. Protect arg by make_cleanup in advance. Simplify memset. Remove TRY_CATCH. Remove explicit xfree. (backtrace_full_command): Remove variable e. Remove TRY_CATCH. --- a/gdb/stack.c +++ b/gdb/stack.c @@ -434,15 +434,17 @@ do_gdb_disassembly (struct gdbarch *gdbarch, { volatile struct gdb_exception exception; - TRY_CATCH (exception, RETURN_MASK_ALL) + TRY_CATCH (exception, RETURN_MASK_ERROR) { gdb_disassembly (gdbarch, uiout, 0, DISASSEMBLY_RAW_INSN, how_many, low, high); } - /* If an exception was thrown while doing the disassembly, print - the error message, to give the user a clue of what happened. */ - if (exception.reason == RETURN_ERROR) - exception_print (gdb_stderr, exception); + if (exception.reason < 0) + { + /* If an exception was thrown while doing the disassembly, print + the error message, to give the user a clue of what happened. */ + exception_print (gdb_stderr, exception); + } } /* Print information about frame FRAME. The output is format according @@ -1348,7 +1350,6 @@ backtrace_command (char *arg, int from_tty) { struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); int fulltrace_arg = -1, arglen = 0, argc = 0; - volatile struct gdb_exception e; if (arg) { @@ -1379,7 +1380,8 @@ backtrace_command (char *arg, int from_tty) if (arglen > 0) { arg = xmalloc (arglen + 1); - memset (arg, 0, arglen + 1); + make_cleanup (xfree, arg); + arg[0] = 0; for (i = 0; i < (argc + 1); i++) { if (i != fulltrace_arg) @@ -1394,13 +1396,7 @@ backtrace_command (char *arg, int from_tty) } } - TRY_CATCH (e, RETURN_MASK_ERROR) - { - backtrace_command_1 (arg, fulltrace_arg >= 0 /* show_locals */, from_tty); - } - - if (fulltrace_arg >= 0 && arglen > 0) - xfree (arg); + backtrace_command_1 (arg, fulltrace_arg >= 0 /* show_locals */, from_tty); do_cleanups (old_chain); } @@ -1408,12 +1404,7 @@ backtrace_command (char *arg, int from_tty) static void backtrace_full_command (char *arg, int from_tty) { - volatile struct gdb_exception e; - - TRY_CATCH (e, RETURN_MASK_ERROR) - { - backtrace_command_1 (arg, 1 /* show_locals */, from_tty); - } + backtrace_command_1 (arg, 1 /* show_locals */, from_tty); }