From: asmwarrior <asmwarrior@gmail.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 28/40] use explicit returns to avoid checker confusion
Date: Fri, 24 May 2013 00:51:00 -0000 [thread overview]
Message-ID: <519EBAE8.9030909@gmail.com> (raw)
In-Reply-To: <27ac4476e9e4f7a238ca9f86ec955ef6d2d21c02.1368124285.git.tromey@redhat.com>
On 2013-5-10 2:52, Tom Tromey wrote:
> The checker does not understand the idiom
>
> if (except.reason < 0) {
> do_cleanups (whatever);
> GDB_PY_HANDLE_EXCEPTION (except);
> }
>
> because it doesn't realize that the nested 'if' actually has the same
> condition.
>
> This fixes instances of this to be more explicit.
>
> * python/py-breakpoint.c (bppy_get_commands): Use
> explicit, unconditional return.
> * python/py-frame.c (frapy_read_var): Likewise.
> * python/python.c (gdbpy_decode_line): Likewise.
> ---
> gdb/python/py-breakpoint.c | 2 +-
> gdb/python/py-frame.c | 2 +-
> gdb/python/python.c | 2 +-
> 3 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
> index d099892..fd13811 100644
> --- a/gdb/python/py-breakpoint.c
> +++ b/gdb/python/py-breakpoint.c
> @@ -492,7 +492,7 @@ bppy_get_commands (PyObject *self, void *closure)
> if (except.reason < 0)
> {
> do_cleanups (chain);
> - GDB_PY_HANDLE_EXCEPTION (except);
> + return gdbpy_convert_exception (except);
> }
>
> cmdstr = ui_file_xstrdup (string_file, &length);
> diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
> index 33d0bd0..10a50ea 100644
> --- a/gdb/python/py-frame.c
> +++ b/gdb/python/py-frame.c
> @@ -472,7 +472,7 @@ frapy_read_var (PyObject *self, PyObject *args)
> if (except.reason < 0)
> {
> do_cleanups (cleanup);
> - GDB_PY_HANDLE_EXCEPTION (except);
> + return gdbpy_convert_exception (except);
> }
>
> if (!var)
> diff --git a/gdb/python/python.c b/gdb/python/python.c
> index 67d06e5..c4be31b 100644
> --- a/gdb/python/python.c
> +++ b/gdb/python/python.c
> @@ -644,7 +644,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
> {
> do_cleanups (cleanups);
> /* We know this will always throw. */
> - GDB_PY_HANDLE_EXCEPTION (except);
> + return gdbpy_convert_exception (except);
> }
>
> if (sals.nelts)
>
I see a compiler error:
mingw32-gcc -O0 -g -D__USE_MINGW_ACCESS -I. -I../../archer/gdb -I../../archer/gdb/common -I../../archer/gdb/config -DLOCALEDIR="\"/mingw/share/locale\"" -DHAVE_CONFIG_H -I../../archer/gdb/../include/opcode -I../../archer/gdb/../opcodes/.. -I../../archer/gdb/../readline/.. -I../bfd -I../../archer/gdb/../bfd -I../../archer/gdb/../include -I../libdecnumber -I../../archer/gdb/../libdecnumber -I../../archer/gdb/gnulib/import -Ibuild-gnulib/import -IE:/code/python27/include -IE:/code/python27/include -Wall -Wdeclaration-after-statement -Wpointer-arith -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Wno-format -Werror -c -o python.o -MT python.o -MMD -MP -MF .deps/python.Tpo -fno-strict-aliasing -DNDEBUG -fwrapv ../../archer/gdb/python/python.c
../../archer/gdb/python/python.c: In function 'gdbpy_decode_line':
../../archer/gdb/python/python.c:656:7: error: void value not ignored as it ought to be
make[2]: *** [python.o] Error 1
make[2]: Leaving directory `/f/build_gdb/abuild/gdb'
make[1]: *** [all-gdb] Error 2
make[1]: Leaving directory `/f/build_gdb/abuild'
make: *** [all] Error 2
I see that: gdbpy_convert_exception (except) return a "void" type, but the function gdbpy_decode_line() need to return a "PyObject *"
The macro GDB_PY_HANDLE_EXCEPTION (except) did return a NULL, see:
/* Use this after a TRY_EXCEPT to throw the appropriate Python
exception. */
#define GDB_PY_HANDLE_EXCEPTION(Exception) \
do { \
if (Exception.reason < 0) \
{ \
gdbpy_convert_exception (Exception); \
return NULL; \
} \
} while (0)
So, what about:
gdbpy_convert_exception (except);
return NULL;
Yuanhui Zhang
next prev parent reply other threads:[~2013-05-24 0:51 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-09 18:47 [PATCH 00/40] add cleanup checker and fix cleanup bugs Tom Tromey, Tom Tromey
2013-05-09 18:48 ` [PATCH 01/40] add the cleanup checker Tom Tromey, Tom Tromey
2013-05-17 16:15 ` Tom Tromey
2013-05-09 18:49 ` [PATCH 03/40] fix print_command_1 Tom Tromey, Tom Tromey
2013-05-09 18:49 ` [PATCH 06/40] remove erroneous return from setup_user_args Tom Tromey, Tom Tromey
2013-05-09 18:49 ` [PATCH 04/40] fix cleanups in som_symtab_read Tom Tromey, Tom Tromey
2013-05-09 18:49 ` [PATCH 05/40] fix cleanup buglet in ada-lang.c Tom Tromey, Tom Tromey
2013-05-30 16:31 ` Tom Tromey
2013-05-09 18:49 ` [PATCH 02/40] some cleanup checker fixes Tom Tromey, Tom Tromey
2013-05-09 18:50 ` [PATCH 08/40] fix up cleanup handling in internal_vproblem Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 16/40] fix varobj.c Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 19/40] fix py-frame.c Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 15/40] make a cleanup unconditionally in tracepoint.c Tom Tromey, Tom Tromey
2013-05-30 9:23 ` Yao Qi
2013-05-30 13:23 ` Tom Tromey
2013-05-09 18:51 ` [PATCH 21/40] fix py-value.c Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 14/40] fix two buglets in breakpoint.c Tom Tromey, Tom Tromey
2013-05-13 2:33 ` Yao Qi
2013-05-13 14:58 ` Tom Tromey
2013-05-13 16:44 ` Tom Tromey
2013-05-14 0:37 ` Yao Qi
2013-05-17 16:19 ` Tom Tromey
2013-05-09 18:51 ` [PATCH 22/40] fix symtab.c Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 11/40] fix list_available_thread_groups Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 13/40] fix cleanup handling in macho_symfile_read Tom Tromey, Tom Tromey
2013-06-03 13:32 ` Joel Brobecker
2013-06-03 16:09 ` Tom Tromey
2013-06-04 13:30 ` Joel Brobecker
2013-06-11 10:21 ` [patch/Darwin] Fix cleanup leak in machoread.c:macho_symfile_read Joel Brobecker
2013-06-18 15:42 ` Tom Tromey
2013-05-09 18:51 ` [PATCH 20/40] fix py-prettyprint.c Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 23/40] fix one bug in symfile.c Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 09/40] cleanup fixes for remote-mips.c Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 18/40] fix py-breakpoint.c Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 10/40] cleanup fixes for inf-ptrace.c Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 24/40] fix mipsread.c Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 12/40] fix cleanup handling in m32r_load Tom Tromey, Tom Tromey
2013-05-09 18:51 ` [PATCH 17/40] simplify cli-logging.c for analysis Tom Tromey, Tom Tromey
2013-05-09 18:52 ` [PATCH 34/40] fix cli-script.c Tom Tromey, Tom Tromey
2013-05-09 18:52 ` [PATCH 30/40] fix linux-thread-db.c Tom Tromey, Tom Tromey
2013-05-09 18:52 ` [PATCH 36/40] introduce dangling_cleanup attribute and change source to use it Tom Tromey, Tom Tromey
2013-05-17 16:17 ` Tom Tromey
2013-05-09 18:52 ` [PATCH 25/40] fix one bug in stabsread.c Tom Tromey, Tom Tromey
2013-05-09 18:52 ` [PATCH 35/40] fix mi-cmd-var.c Tom Tromey, Tom Tromey
2013-05-17 16:16 ` Tom Tromey
2013-05-09 18:52 ` [PATCH 32/40] fix dbxread.c Tom Tromey, Tom Tromey
2013-05-09 18:52 ` [PATCH 26/40] fix top.c Tom Tromey, Tom Tromey
2013-05-09 18:52 ` [PATCH 29/40] fix in solib-aix.c Tom Tromey, Tom Tromey
2013-05-09 18:52 ` [PATCH 33/40] fix mi-cmd-stack.c Tom Tromey, Tom Tromey
2013-05-09 18:52 ` [PATCH 31/40] fix source.c Tom Tromey, Tom Tromey
2013-05-09 18:52 ` [PATCH 28/40] use explicit returns to avoid checker confusion Tom Tromey, Tom Tromey
2013-05-24 0:51 ` asmwarrior [this message]
2013-05-24 1:30 ` Tom Tromey
2013-05-24 15:41 ` Tom Tromey
2013-05-26 11:21 ` asmwarrior
2013-05-09 18:52 ` [PATCH 27/40] fix cp-namespace.c Tom Tromey, Tom Tromey
2013-05-09 18:53 ` [PATCH 40/40] fix up xml-support.c Tom Tromey, Tom Tromey
2013-05-30 17:41 ` Tom Tromey
2013-05-09 18:53 ` [PATCH 38/40] some fixes to infrun.c Tom Tromey, Tom Tromey
2013-05-17 16:21 ` Tom Tromey
2013-05-09 18:53 ` [PATCH 37/40] fix breakpoint_1 Tom Tromey, Tom Tromey
2013-05-17 16:18 ` Tom Tromey
2013-05-09 18:53 ` [PATCH 39/40] fix compile_rx_or_error Tom Tromey, Tom Tromey
2013-05-13 2:53 ` Yao Qi
2013-05-13 14:59 ` Tom Tromey
2013-05-30 17:39 ` Tom Tromey
2013-05-09 19:45 ` [PATCH 07/40] fix linespec bug noticed by the checker Tom Tromey, Tom Tromey
2013-05-09 21:21 ` [PATCH 00/40] add cleanup checker and fix cleanup bugs Phil Muldoon
2013-05-10 14:27 ` Tom Tromey
2013-05-10 8:23 ` Joel Brobecker
2013-05-10 14:34 ` Tom Tromey
2013-05-11 10:41 ` Joel Brobecker
2013-05-14 19:04 ` Tom Tromey
2013-05-30 16:17 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=519EBAE8.9030909@gmail.com \
--to=asmwarrior@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox