From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 34/36] more making TRY/CATCH callers look more like real C++ try/catch blocks
Date: Mon, 09 Feb 2015 23:50:00 -0000 [thread overview]
Message-ID: <1423524046-20605-35-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1423524046-20605-1-git-send-email-palves@redhat.com>
All these were caught by actually making TRY/CATCH use try/catch
behind the scenes, which then resulted in the build failing because
there was code between the try and catch blocks.
As with the prior patch, this could either be done _before_ running
the TRY_CATCH conversion script, or be squashed into it.
---
gdb/breakpoint.c | 5 +++--
gdb/gdbtypes.c | 24 ++++++++++++++----------
gdb/guile/scm-frame.c | 9 +++------
gdb/linux-thread-db.c | 10 ++++++----
gdb/python/py-breakpoint.c | 3 ++-
gdb/record-btrace.c | 20 ++++++++++----------
6 files changed, 38 insertions(+), 33 deletions(-)
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index b5a9704..4db4084 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -15899,6 +15899,7 @@ save_breakpoints (char *filename, int from_tty,
if (tp->type != bp_dprintf && tp->commands)
{
+ struct gdb_exception exception;
fprintf_unfiltered (fp, " commands\n");
@@ -15907,14 +15908,14 @@ save_breakpoints (char *filename, int from_tty,
{
print_command_lines (current_uiout, tp->commands->commands, 2);
}
- ui_out_redirect (current_uiout, NULL);
-
CATCH (ex, RETURN_MASK_ALL)
{
+ ui_out_redirect (current_uiout, NULL);
throw_exception (ex);
}
END_CATCH
+ ui_out_redirect (current_uiout, NULL);
fprintf_unfiltered (fp, " end\n");
}
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 54130b6..ff3bdf4 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2301,7 +2301,6 @@ safe_parse_type (struct gdbarch *gdbarch, char *p, int length)
{
type = parse_and_eval_type (p, length);
}
-
CATCH (except, RETURN_MASK_ERROR)
{
type = builtin_type (gdbarch)->builtin_void;
@@ -3229,6 +3228,7 @@ check_types_worklist (VEC (type_equality_entry_d) **worklist,
int
types_deeply_equal (struct type *type1, struct type *type2)
{
+ struct gdb_exception except = exception_none;
int result = 0;
struct bcache *cache;
VEC (type_equality_entry_d) *worklist = NULL;
@@ -3246,23 +3246,27 @@ types_deeply_equal (struct type *type1, struct type *type2)
entry.type2 = type2;
VEC_safe_push (type_equality_entry_d, worklist, &entry);
+ /* check_types_worklist calls several nested helper functions, some
+ of which can raise a GDB exception, so we just check and rethrow
+ here. If there is a GDB exception, a comparison is not capable
+ (or trusted), so exit. */
TRY
{
result = check_types_worklist (&worklist, cache);
}
- /* check_types_worklist calls several nested helper functions,
- some of which can raise a GDB Exception, so we just check
- and rethrow here. If there is a GDB exception, a comparison
- is not capable (or trusted), so exit. */
- bcache_xfree (cache);
- VEC_free (type_equality_entry_d, worklist);
- /* Rethrow if there was a problem. */
- CATCH (except, RETURN_MASK_ALL)
+ CATCH (ex, RETURN_MASK_ALL)
{
- throw_exception (except);
+ except = ex;
}
END_CATCH
+ bcache_xfree (cache);
+ VEC_free (type_equality_entry_d, worklist);
+
+ /* Rethrow if there was a problem. */
+ if (except.reason < 0)
+ throw_exception (except);
+
return result;
}
\f
diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c
index 6189802..ea51d1b 100644
--- a/gdb/guile/scm-frame.c
+++ b/gdb/guile/scm-frame.c
@@ -426,7 +426,6 @@ gdbscm_frame_name (SCM self)
enum language lang = language_minimal;
struct frame_info *frame = NULL;
SCM result;
- struct gdb_exception except = exception_none;
f_smob = frscm_get_frame_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
@@ -436,15 +435,13 @@ gdbscm_frame_name (SCM self)
if (frame != NULL)
find_frame_funname (frame, &name, &lang, NULL);
}
- CATCH (ex, RETURN_MASK_ALL)
+ CATCH (except, RETURN_MASK_ALL)
{
- except = ex;
+ xfree (name);
+ GDBSCM_HANDLE_GDB_EXCEPTION (except);
}
END_CATCH
- xfree (name);
- GDBSCM_HANDLE_GDB_EXCEPTION (except);
-
if (frame == NULL)
{
gdbscm_invalid_object_error (FUNC_NAME, SCM_ARG1, self,
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 87596d2..74f7e69 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -1730,16 +1730,18 @@ find_new_threads_once (struct thread_db_info *info, int iteration,
TD_SIGNO_MASK,
TD_THR_ANY_USER_FLAGS);
}
-
- if (libthread_db_debug)
+ CATCH (except, RETURN_MASK_ERROR)
{
- CATCH (except, RETURN_MASK_ERROR)
+ if (libthread_db_debug)
{
exception_fprintf (gdb_stdlog, except,
"Warning: find_new_threads_once: ");
}
- END_CATCH
+ }
+ END_CATCH
+ if (libthread_db_debug)
+ {
fprintf_unfiltered (gdb_stdlog,
_("Found %d new threads in iteration %d.\n"),
data.new_threads, iteration);
diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c
index dcf1d5a..42a8596 100644
--- a/gdb/python/py-breakpoint.c
+++ b/gdb/python/py-breakpoint.c
@@ -503,15 +503,16 @@ bppy_get_commands (PyObject *self, void *closure)
{
print_command_lines (current_uiout, breakpoint_commands (bp), 0);
}
- ui_out_redirect (current_uiout, NULL);
CATCH (except, RETURN_MASK_ALL)
{
+ ui_out_redirect (current_uiout, NULL);
do_cleanups (chain);
gdbpy_convert_exception (except);
return NULL;
}
END_CATCH
+ ui_out_redirect (current_uiout, NULL);
cmdstr = ui_file_xstrdup (string_file, &length);
make_cleanup (xfree, cmdstr);
result = PyString_Decode (cmdstr, strlen (cmdstr), host_charset (), NULL);
diff --git a/gdb/record-btrace.c b/gdb/record-btrace.c
index 1cbbd3e..8aedb0b 100644
--- a/gdb/record-btrace.c
+++ b/gdb/record-btrace.c
@@ -1116,14 +1116,13 @@ record_btrace_insert_breakpoint (struct target_ops *ops,
{
ret = ops->beneath->to_insert_breakpoint (ops->beneath, gdbarch, bp_tgt);
}
-
- replay_memory_access = old;
-
CATCH (except, RETURN_MASK_ALL)
{
+ replay_memory_access = old;
throw_exception (except);
}
END_CATCH
+ replay_memory_access = old;
return ret;
}
@@ -1148,14 +1147,13 @@ record_btrace_remove_breakpoint (struct target_ops *ops,
{
ret = ops->beneath->to_remove_breakpoint (ops->beneath, gdbarch, bp_tgt);
}
-
- replay_memory_access = old;
-
CATCH (except, RETURN_MASK_ALL)
{
+ replay_memory_access = old;
throw_exception (except);
}
END_CATCH
+ replay_memory_access = old;
return ret;
}
@@ -1667,12 +1665,11 @@ record_btrace_start_replaying (struct thread_info *tp)
if (upd_step_stack_frame_id)
tp->control.step_stack_frame_id = frame_id;
}
-
- /* Restore the previous execution state. */
- set_executing (tp->ptid, executing);
-
CATCH (except, RETURN_MASK_ALL)
{
+ /* Restore the previous execution state. */
+ set_executing (tp->ptid, executing);
+
xfree (btinfo->replay);
btinfo->replay = NULL;
@@ -1682,6 +1679,9 @@ record_btrace_start_replaying (struct thread_info *tp)
}
END_CATCH
+ /* Restore the previous execution state. */
+ set_executing (tp->ptid, executing);
+
return replay;
}
--
1.9.3
next prev parent reply other threads:[~2015-02-09 23:50 UTC|newest]
Thread overview: 100+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-09 23:20 [PATCH 00/36] Support building GDB as a C++ program Pedro Alves
2015-02-09 23:20 ` [PATCH 02/36] Add --enable-build-with-cxx configure switch Pedro Alves
2015-02-10 22:11 ` Yao Qi
2015-02-27 13:24 ` Pedro Alves
2015-02-27 14:20 ` Yao Qi
2015-02-27 16:29 ` Pedro Alves
2015-02-09 23:21 ` [PATCH 31/36] Split TRY_CATCH into TRY + CATCH Pedro Alves
2015-03-07 15:58 ` Pedro Alves
2015-02-09 23:21 ` [PATCH 12/36] proc-service, extern "C" Pedro Alves
2015-02-09 23:21 ` [PATCH 22/36] Remove duplicate const Pedro Alves
2015-02-09 23:21 ` [PATCH 15/36] Don't forward declare enum target_hw_bp_type Pedro Alves
2015-02-09 23:21 ` [PATCH 23/36] gdbarch.h: include regcache.h Pedro Alves
2015-02-09 23:21 ` [PATCH 21/36] opcodes/microblaze: Rename 'or', 'and', 'xor' to avoid C++ conflict Pedro Alves
2015-02-10 15:05 ` Michael Eager
2015-02-10 18:11 ` Pedro Alves
2015-02-09 23:21 ` [PATCH 13/36] target.h: Include infrun.h Pedro Alves
2015-02-09 23:21 ` [PATCH 05/36] Fix redefinition errors in C++ mode Pedro Alves
2015-02-11 10:09 ` Yao Qi
2015-02-11 11:30 ` Pedro Alves
2015-02-11 11:39 ` [PATCH] xcoffread.c: delete 'within_function' definition (Re: [PATCH 05/36] Fix redefinition errors in C++ mode) Pedro Alves
2015-02-09 23:21 ` [PATCH 20/36] gdbserver/tracepoint: Add cast sockaddr_un/sockaddr cast Pedro Alves
2015-02-09 23:21 ` [PATCH 08/36] elf-bfd.h: Wrap in extern "C" Pedro Alves
2015-02-09 23:33 ` Andrew Pinski
2015-02-10 12:05 ` [PATCH v2] Wrap BFD headers " Pedro Alves
2015-02-11 0:36 ` Alan Modra
2015-02-11 10:08 ` Pedro Alves
2015-02-09 23:21 ` [PATCH 09/36] floatformat.h: Wrap " Pedro Alves
2015-02-09 23:35 ` Andrew Pinski
2015-02-09 23:49 ` Pedro Alves
2015-02-12 11:49 ` Pedro Alves
2015-02-18 19:55 ` Jakub Jelinek
2015-02-14 17:29 ` Doug Evans
2015-02-14 18:36 ` Pedro Alves
2015-02-14 22:46 ` Doug Evans
2015-02-09 23:21 ` [PATCH 16/36] x86 Linux/ptrace: fix offsetof usage in C++ mode Pedro Alves
2015-02-09 23:21 ` [PATCH 19/36] Exported const objects Pedro Alves
2015-02-09 23:21 ` [PATCH 03/36] C++ keyword cleanliness, mostly auto-generated Pedro Alves
2015-02-11 7:57 ` Joel Brobecker
2015-02-11 8:52 ` Phil Muldoon
2015-02-11 10:27 ` Pedro Alves
2015-02-11 10:51 ` Pedro Alves
2015-02-12 12:19 ` Joel Brobecker
2015-02-12 13:14 ` Pedro Alves
2015-02-12 14:43 ` Pedro Alves
2015-02-12 14:59 ` Joel Brobecker
2015-02-27 17:41 ` Pedro Alves
2015-02-09 23:21 ` [PATCH 17/36] mi/mi-cmd-stack.c|frame filters: print_values <-> ext_lang_frame_args Pedro Alves
2015-02-09 23:21 ` [PATCH 28/36] Move exception_none to common code, and use it Pedro Alves
2015-02-09 23:21 ` [PATCH 25/36] python/python-internal.h: enum ‘ext_lang_rc’ not defined Pedro Alves
2015-02-09 23:21 ` [PATCH 27/36] catch_command_errors: Remove 'mask' parameter Pedro Alves
2015-02-09 23:21 ` [PATCH 29/36] Normalize TRY_CATCH exception handling block Pedro Alves
2015-02-09 23:21 ` [PATCH 26/36] Adjust self tests to cope with GDB built as a C++ program Pedro Alves
2015-02-09 23:21 ` [PATCH 04/36] Fix struct, union, and enum nesting in C++ Pedro Alves
2015-02-09 23:21 ` [PATCH 11/36] Make functions and variables exported by the IPA be extern "C" Pedro Alves
2015-02-09 23:22 ` [PATCH 33/36] TRY_CATCH -> TRY+CATCH+END_CATCH, the manual conversions Pedro Alves
2015-02-09 23:22 ` [PATCH 36/36] Make TRY/CATCH use real C++ try/catch in C++ mode Pedro Alves
2015-02-09 23:22 ` [PATCH 32/36] TRY_CATCH -> TRY+CATCH+END_CATCH everywhere Pedro Alves
2015-02-09 23:35 ` [PATCH 18/36] Rename struct lzma_stream to avoid clash with system header Pedro Alves
2015-02-09 23:45 ` [PATCH 06/36] record-btrace.c: Remove redefinitions Pedro Alves
2015-02-09 23:46 ` [PATCH 35/36] kill volatile struct gdb_exception Pedro Alves
2015-02-09 23:49 ` [PATCH 00/36] Support building GDB as a C++ program Doug Evans
2015-02-09 23:50 ` Pedro Alves [this message]
2015-03-07 15:59 ` [PATCH 34/36] more making TRY/CATCH callers look more like real C++ try/catch blocks Pedro Alves
2015-02-09 23:51 ` [PATCH 14/36] Do not do arithmetic on enum types Pedro Alves
2015-02-09 23:51 ` [PATCH 07/36] Make array object extern Pedro Alves
2015-02-27 22:47 ` Simon Marchi
2015-02-27 22:58 ` Pedro Alves
2015-02-27 23:04 ` Simon Marchi
2015-02-09 23:53 ` [PATCH 01/36] Create libiberty/libiberty.m4, have GDB and GDBserver use it Pedro Alves
2015-02-09 23:35 ` Pedro Alves
2015-02-27 16:23 ` Pedro Alves
2015-02-09 23:54 ` [PATCH 10/36] Add extern "C" to declarations of C symbols Pedro Alves
2015-02-11 11:51 ` Pedro Alves
2015-02-09 23:54 ` [PATCH 30/36] quit_force: Replace TRY_CATCH wrapper macros Pedro Alves
2015-02-10 0:21 ` [PATCH 24/36] breakpoint.h: move enum ‘print_stop_action’ Pedro Alves
2015-02-11 12:28 ` Yao Qi
2015-02-10 15:07 ` [PATCH 00/36] Support building GDB as a C++ program Michael Eager
2015-02-11 17:15 ` Yao Qi
2015-02-12 11:34 ` Pedro Alves
2015-02-17 23:19 ` Patrick Palka
2015-02-18 21:54 ` Yao Qi
2015-02-18 23:49 ` Patrick Palka
2015-02-27 18:19 ` Pedro Alves
2015-02-27 23:52 ` Patrick Palka
2015-02-28 0:09 ` Pedro Alves
2015-03-07 16:01 ` Pedro Alves
2015-03-07 17:58 ` [all pushed] " Pedro Alves
2015-03-16 4:42 ` asmwarrior
2015-03-16 5:05 ` asmwarrior
2015-03-16 5:22 ` asmwarrior
2015-03-16 7:15 ` asmwarrior
2015-03-16 8:20 ` asmwarrior
2015-03-16 11:43 ` [pushed] stub-termcap.c: prototype tputs's parameter's parameter, for C++ mode (Re: [all pushed] Re: [PATCH 00/36] Support building GDB as a C++ program) Pedro Alves
2015-03-16 11:46 ` [pushed] stub termcap, add extern "C" " Pedro Alves
2015-03-16 11:55 ` [all pushed] Re: [PATCH 00/36] Support building GDB as a C++ program Pedro Alves
2015-03-16 11:42 ` Pedro Alves
2015-05-15 8:13 ` asmwarrior
2015-05-15 8:24 ` asmwarrior
2015-05-15 15:09 ` Pedro Alves
2015-05-15 15:04 ` Pedro Alves
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=1423524046-20605-35-git-send-email-palves@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
/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