* [patch 2/2] Mostly code cleanup: stack.c: TRY_CATCH simplifications
@ 2011-07-31 1:03 Jan Kratochvil
2011-08-01 14:34 ` Tom Tromey
0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2011-07-31 1:03 UTC (permalink / raw)
To: gdb-patches
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 <jan.kratochvil@redhat.com>
* 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);
}
\f
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 2/2] Mostly code cleanup: stack.c: TRY_CATCH simplifications
2011-07-31 1:03 [patch 2/2] Mostly code cleanup: stack.c: TRY_CATCH simplifications Jan Kratochvil
@ 2011-08-01 14:34 ` Tom Tromey
2011-08-01 14:59 ` Jan Kratochvil
0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2011-08-01 14:34 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: gdb-patches
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> after [patch 1/2] some constructs become obviously redundant.
FWIW, I like both these patches.
Jan> This is a "code cleanup" except for the RETURN_MASK_ALL change. I haven't
Jan> found any specific reason in the mail thread introducing it and neither any
Jan> reason in the current code, IMO it was only a mistake.
I looked at it, and I agree.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch 2/2] Mostly code cleanup: stack.c: TRY_CATCH simplifications
2011-08-01 14:34 ` Tom Tromey
@ 2011-08-01 14:59 ` Jan Kratochvil
0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2011-08-01 14:59 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On Mon, 01 Aug 2011 16:34:19 +0200, Tom Tromey wrote:
> >>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>
> Jan> after [patch 1/2] some constructs become obviously redundant.
>
> FWIW, I like both these patches.
OK, checked in also this one:
http://sourceware.org/ml/gdb-cvs/2011-08/msg00004.html
Thanks,
Jan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-08-01 14:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-31 1:03 [patch 2/2] Mostly code cleanup: stack.c: TRY_CATCH simplifications Jan Kratochvil
2011-08-01 14:34 ` Tom Tromey
2011-08-01 14:59 ` Jan Kratochvil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox