• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisionbea0a5aeece991b2f4f20a746ce655283607d9a6 (tree)
Time2017-09-28 06:43:26
AuthorPedro Alves <palves@redh...>
CommiterPedro Alves

Log Message

zap catch_errors

Change Summary

Incremental Difference

--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -103,8 +103,6 @@ static void map_breakpoint_numbers (const char *,
103103
104104 static void ignore_command (char *, int);
105105
106-static int breakpoint_re_set_one (void *);
107-
108106 static void breakpoint_re_set_default (struct breakpoint *);
109107
110108 static void
@@ -178,8 +176,6 @@ static void info_breakpoints_command (char *, int);
178176
179177 static void info_watchpoints_command (char *, int);
180178
181-static int breakpoint_cond_eval (void *);
182-
183179 static void cleanup_executing_breakpoints (void *);
184180
185181 static void commands_command (char *, int);
@@ -191,8 +187,6 @@ static int remove_breakpoint_1 (struct bp_location *, enum remove_bp_reason);
191187
192188 static enum print_stop_action print_bp_stop_message (bpstat bs);
193189
194-static int watchpoint_check (void *);
195-
196190 static int hw_breakpoint_used_count (void);
197191
198192 static int hw_watchpoint_use_count (struct breakpoint *);
@@ -4842,21 +4836,16 @@ bpstat_print (bpstat bs, int kind)
48424836 return PRINT_UNKNOWN;
48434837 }
48444838
4845-/* Evaluate the expression EXP and return 1 if value is zero.
4846- This returns the inverse of the condition because it is called
4847- from catch_errors which returns 0 if an exception happened, and if an
4848- exception happens we want execution to stop.
4849- The argument is a "struct expression *" that has been cast to a
4850- "void *" to make it pass through catch_errors. */
4839+/* Evaluate the boolean expression EXP and return the result. */
48514840
4852-static int
4853-breakpoint_cond_eval (void *exp)
4841+static bool
4842+breakpoint_cond_eval (expression *exp)
48544843 {
48554844 struct value *mark = value_mark ();
4856- int i = !value_true (evaluate_expression ((struct expression *) exp));
4845+ bool res = value_true (evaluate_expression (exp));
48574846
48584847 value_free_to_mark (mark);
4859- return i;
4848+ return res;
48604849 }
48614850
48624851 /* Allocate a new bpstat. Link it to the FIFO list by BS_LINK_POINTER. */
@@ -4966,30 +4955,28 @@ watchpoints_triggered (struct target_waitstatus *ws)
49664955 return 1;
49674956 }
49684957
4969-/* Possible return values for watchpoint_check (this can't be an enum
4970- because of check_errors). */
4971-/* The watchpoint has been deleted. */
4972-#define WP_DELETED 1
4973-/* The value has changed. */
4974-#define WP_VALUE_CHANGED 2
4975-/* The value has not changed. */
4976-#define WP_VALUE_NOT_CHANGED 3
4977-/* Ignore this watchpoint, no matter if the value changed or not. */
4978-#define WP_IGNORE 4
4958+/* Possible return values for watchpoint_check. */
4959+enum wp_check_result
4960+ {
4961+ /* The watchpoint has been deleted. */
4962+ WP_DELETED = 1,
4963+ /* The value has changed. */
4964+ WP_VALUE_CHANGED = 2,
4965+ /* The value has not changed. */
4966+ WP_VALUE_NOT_CHANGED = 3,
4967+ /* Ignore this watchpoint, no matter if the value changed or not. */
4968+ WP_IGNORE = 4,
4969+ };
49794970
49804971 #define BP_TEMPFLAG 1
49814972 #define BP_HARDWAREFLAG 2
49824973
49834974 /* Evaluate watchpoint condition expression and check if its value
4984- changed.
4985-
4986- P should be a pointer to struct bpstat, but is defined as a void *
4987- in order for this function to be usable with catch_errors. */
4975+ changed. */
49884976
4989-static int
4990-watchpoint_check (void *p)
4977+static wp_check_result
4978+watchpoint_check (bpstat bs)
49914979 {
4992- bpstat bs = (bpstat) p;
49934980 struct watchpoint *b;
49944981 struct frame_info *fr;
49954982 int within_current_scope;
@@ -5185,16 +5172,29 @@ bpstat_check_watchpoint (bpstat bs)
51855172
51865173 if (must_check_value)
51875174 {
5188- char *message
5189- = xstrprintf ("Error evaluating expression for watchpoint %d\n",
5190- b->number);
5191- struct cleanup *cleanups = make_cleanup (xfree, message);
5192- int e = catch_errors ([&] ()
5193- {
5194- return watchpoint_check (bs);
5195- },
5196- message, RETURN_MASK_ALL);
5197- do_cleanups (cleanups);
5175+ wp_check_result e;
5176+
5177+ TRY
5178+ {
5179+ e = watchpoint_check (bs);
5180+ }
5181+ CATCH (ex, RETURN_MASK_ALL)
5182+ {
5183+ exception_fprintf (gdb_stderr, ex,
5184+ "Error evaluating expression "
5185+ "for watchpoint %d\n",
5186+ b->number);
5187+
5188+ SWITCH_THRU_ALL_UIS ()
5189+ {
5190+ printf_filtered (_("Watchpoint %d deleted.\n"),
5191+ b->number);
5192+ }
5193+ watchpoint_del_at_next_stop (b);
5194+ e = WP_DELETED;
5195+ }
5196+ END_CATCH
5197+
51985198 switch (e)
51995199 {
52005200 case WP_DELETED:
@@ -5290,18 +5290,6 @@ bpstat_check_watchpoint (bpstat bs)
52905290 break;
52915291 default:
52925292 /* Can't happen. */
5293- case 0:
5294- /* Error from catch_errors. */
5295- {
5296- SWITCH_THRU_ALL_UIS ()
5297- {
5298- printf_filtered (_("Watchpoint %d deleted.\n"),
5299- b->number);
5300- }
5301- watchpoint_del_at_next_stop (b);
5302- /* We've already printed what needs to be printed. */
5303- bs->print_it = print_it_done;
5304- }
53055293 break;
53065294 }
53075295 }
@@ -5327,7 +5315,8 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
53275315 {
53285316 const struct bp_location *bl;
53295317 struct breakpoint *b;
5330- int value_is_zero = 0;
5318+ /* Assume stop. */
5319+ bool condition_result = true;
53315320 struct expression *cond;
53325321
53335322 gdb_assert (bs->stop);
@@ -5423,26 +5412,30 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid)
54235412 within_current_scope = 0;
54245413 }
54255414 if (within_current_scope)
5426- value_is_zero
5427- = catch_errors ([&] ()
5428- {
5429- return breakpoint_cond_eval (cond);
5430- },
5431- "Error in testing breakpoint condition:\n",
5432- RETURN_MASK_ALL);
5415+ {
5416+ TRY
5417+ {
5418+ condition_result = breakpoint_cond_eval (cond);
5419+ }
5420+ CATCH (ex, RETURN_MASK_ALL)
5421+ {
5422+ exception_fprintf (gdb_stderr, ex,
5423+ "Error in testing breakpoint condition:\n");
5424+ }
5425+ END_CATCH
5426+ }
54335427 else
54345428 {
54355429 warning (_("Watchpoint condition cannot be tested "
54365430 "in the current scope"));
54375431 /* If we failed to set the right context for this
54385432 watchpoint, unconditionally report it. */
5439- value_is_zero = 0;
54405433 }
54415434 /* FIXME-someday, should give breakpoint #. */
54425435 value_free_to_mark (mark);
54435436 }
54445437
5445- if (cond && value_is_zero)
5438+ if (cond && !condition_result)
54465439 {
54475440 bs->stop = 0;
54485441 }
@@ -14149,21 +14142,16 @@ prepare_re_set_context (struct breakpoint *b)
1414914142 return make_cleanup (null_cleanup, NULL);
1415014143 }
1415114144
14152-/* Reset a breakpoint given it's struct breakpoint * BINT.
14153- The value we return ends up being the return value from catch_errors.
14154- Unused in this case. */
14145+/* Reset a breakpoint. */
1415514146
14156-static int
14157-breakpoint_re_set_one (void *bint)
14147+static void
14148+breakpoint_re_set_one (breakpoint *b)
1415814149 {
14159- /* Get past catch_errs. */
14160- struct breakpoint *b = (struct breakpoint *) bint;
1416114150 struct cleanup *cleanups;
1416214151
1416314152 cleanups = prepare_re_set_context (b);
1416414153 b->ops->re_set (b);
1416514154 do_cleanups (cleanups);
14166- return 0;
1416714155 }
1416814156
1416914157 /* Re-set breakpoint locations for the current program space.
@@ -14189,16 +14177,17 @@ breakpoint_re_set (void)
1418914177
1419014178 ALL_BREAKPOINTS_SAFE (b, b_tmp)
1419114179 {
14192- /* Format possible error msg. */
14193- char *message = xstrprintf ("Error in re-setting breakpoint %d: ",
14194- b->number);
14195- struct cleanup *cleanups = make_cleanup (xfree, message);
14196- catch_errors ([&] ()
14197- {
14198- return breakpoint_re_set_one (b);
14199- },
14200- message, RETURN_MASK_ALL);
14201- do_cleanups (cleanups);
14180+ TRY
14181+ {
14182+ breakpoint_re_set_one (b);
14183+ }
14184+ CATCH (ex, RETURN_MASK_ALL)
14185+ {
14186+ exception_fprintf (gdb_stderr, ex,
14187+ "Error in re-setting breakpoint %d: ",
14188+ b->number);
14189+ }
14190+ END_CATCH
1420214191 }
1420314192 set_language (save_language);
1420414193 input_radix = save_input_radix;
--- a/gdb/exceptions.c
+++ b/gdb/exceptions.c
@@ -215,45 +215,6 @@ catch_exceptions_with_msg (struct ui_out *func_uiout,
215215 return val;
216216 }
217217
218-/* This function is superseded by catch_exceptions(). */
219-
220-int
221-catch_errors (gdb::function_view<catch_errors_ftype> func,
222- const char *errstring, return_mask mask)
223-{
224- struct gdb_exception exception = exception_none;
225- volatile int val = 0;
226- struct ui_out *saved_uiout;
227-
228- /* Save the global ``struct ui_out'' builder. */
229- saved_uiout = current_uiout;
230-
231- TRY
232- {
233- val = func ();
234- }
235- CATCH (ex, RETURN_MASK_ALL)
236- {
237- exception = ex;
238- }
239- END_CATCH
240-
241- /* Restore the global builder. */
242- current_uiout = saved_uiout;
243-
244- if (exception.reason < 0 && (mask & RETURN_MASK (exception.reason)) == 0)
245- {
246- /* The caller didn't request that the event be caught.
247- Rethrow. */
248- throw_exception (exception);
249- }
250-
251- exception_fprintf (gdb_stderr, exception, "%s", errstring);
252- if (exception.reason != 0)
253- return 0;
254- return val;
255-}
256-
257218 /* See exceptions.h. */
258219
259220 int
--- a/gdb/exceptions.h
+++ b/gdb/exceptions.h
@@ -48,21 +48,16 @@ extern void exception_fprintf (struct ui_file *file, struct gdb_exception e,
4848 copy of the gdb error message. This is used when a silent error is
4949 issued and the caller wants to manually issue the error message.
5050
51- MASK specifies what to catch; it is normally set to
52- RETURN_MASK_ALL, if for no other reason than that the code which
53- calls catch_errors might not be set up to deal with a quit which
54- isn't caught. But if the code can deal with it, it generally
55- should be RETURN_MASK_ERROR, unless for some reason it is more
56- useful to abort only the portion of the operation inside the
57- catch_errors. Note that quit should return to the command line
51+ MASK specifies what to catch; it is normally set to RETURN_MASK_ALL
52+ if the code which calls catch_exceptions is not set up to deal with
53+ a quit which isn't caught. But if the code can deal with it, it
54+ generally should be RETURN_MASK_ERROR, unless for some reason it is
55+ more useful to abort only the portion of the operation inside the
56+ catch_exceptions. Note that quit should return to the command line
5857 fairly quickly, even if some further processing is being done.
5958
6059 FIXME; cagney/2001-08-13: The need to override the global UIOUT
61- builder variable should just go away.
62-
63- This function supersedes catch_errors().
64-
65- This function uses SETJMP() and LONGJUMP(). */
60+ builder variable should just go away. */
6661
6762 struct ui_out;
6863 typedef int (catch_exceptions_ftype) (struct ui_out *ui_out);
@@ -75,19 +70,6 @@ extern int catch_exceptions_with_msg
7570 char **gdberrmsg,
7671 return_mask mask);
7772
78-/* If CATCH_ERRORS_FTYPE throws an error, catch_errors() returns zero
79- otherwize the result from CATCH_ERRORS_FTYPE is returned. It is
80- probably useful for CATCH_ERRORS_FTYPE to always return a non-zero
81- value. It's unfortunate that, catch_errors() does not return an
82- indication of the exact exception that it caught - quit_flag might
83- help.
84-
85- This function is superseded by catch_exceptions(). */
86-
87-typedef int (catch_errors_ftype) ();
88-extern int catch_errors (gdb::function_view<catch_errors_ftype>,
89- const char *, return_mask);
90-
9173 /* Compare two exception objects for print equality. */
9274 extern int exception_print_same (struct gdb_exception e1,
9375 struct gdb_exception e2);
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8308,12 +8308,16 @@ normal_stop (void)
83088308 struct cleanup *old_chain
83098309 = make_cleanup (release_stop_context_cleanup, saved_context);
83108310
8311- catch_errors ([&] ()
8312- {
8313- execute_cmd_pre_hook (stop_command);
8314- return 0;
8315- },
8316- "Error while running hook_stop:\n", RETURN_MASK_ALL);
8311+ TRY
8312+ {
8313+ execute_cmd_pre_hook (stop_command);
8314+ }
8315+ CATCH (ex, RETURN_MASK_ALL)
8316+ {
8317+ exception_fprintf (gdb_stderr, ex,
8318+ "Error while running hook_stop:\n");
8319+ }
8320+ END_CATCH
83178321
83188322 /* If the stop hook resumes the target, then there's no point in
83198323 trying to notify about the previous stop; its context is
@@ -9021,19 +9025,22 @@ restore_infcall_control_state (struct infcall_control_state *inf_status)
90219025
90229026 if (target_has_stack)
90239027 {
9024- /* The point of catch_errors is that if the stack is clobbered,
9028+ /* The point of the try/catch is that if the stack is clobbered,
90259029 walking the stack might encounter a garbage pointer and
90269030 error() trying to dereference it. */
9027- if (catch_errors
9028- ([&] ()
9029- {
9030- return restore_selected_frame (&inf_status->selected_frame_id);
9031- },
9032- "Unable to restore previously selected frame:\n",
9033- RETURN_MASK_ERROR) == 0)
9034- /* Error in restoring the selected frame. Select the innermost
9035- frame. */
9036- select_frame (get_current_frame ());
9031+ TRY
9032+ {
9033+ restore_selected_frame (&inf_status->selected_frame_id);
9034+ }
9035+ CATCH (ex, RETURN_MASK_ERROR)
9036+ {
9037+ exception_fprintf (gdb_stderr, ex,
9038+ "Unable to restore previously selected frame:\n");
9039+ /* Error in restoring the selected frame. Select the
9040+ innermost frame. */
9041+ select_frame (get_current_frame ());
9042+ }
9043+ END_CATCH
90379044 }
90389045
90399046 xfree (inf_status);
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1147,7 +1147,15 @@ captured_main (void *data)
11471147 change - SET_TOP_LEVEL() - has been eliminated. */
11481148 while (1)
11491149 {
1150- catch_errors (captured_command_loop, "", RETURN_MASK_ALL);
1150+ TRY
1151+ {
1152+ captured_command_loop ();
1153+ }
1154+ CATCH (ex, RETURN_MASK_ALL)
1155+ {
1156+ exception_print (gdb_stderr, ex);
1157+ }
1158+ END_CATCH
11511159 }
11521160 /* No exit -- exit is through quit_command. */
11531161 }
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -1315,19 +1315,19 @@ find_objc_msgcall_submethod (int (*f) (CORE_ADDR, CORE_ADDR *),
13151315 CORE_ADDR pc,
13161316 CORE_ADDR *new_pc)
13171317 {
1318- if (catch_errors ([&] ()
1319- {
1320- if (f (pc, new_pc) == 0)
1321- return 1;
1322- else
1323- return 0;
1324- },
1325- "Unable to determine target of "
1326- "Objective-C method call (ignoring):\n",
1327- RETURN_MASK_ALL) == 0)
1328- return 1;
1329- else
1330- return 0;
1318+ TRY
1319+ {
1320+ if (f (pc, new_pc) == 0)
1321+ return 1;
1322+ }
1323+ CATCH (ex, RETURN_MASK_ALL)
1324+ {
1325+ exception_fprintf (gdb_stderr, ex,
1326+ "Unable to determine target of "
1327+ "Objective-C method call (ignoring):\n");
1328+ }
1329+
1330+ return 0;
13311331 }
13321332
13331333 int
--- a/gdb/record-full.c
+++ b/gdb/record-full.c
@@ -565,7 +565,7 @@ record_full_arch_list_cleanups (void *ignore)
565565 record the running message of inferior and set them to
566566 record_full_arch_list, and add it to record_full_list. */
567567
568-static int
568+static void
569569 record_full_message (struct regcache *regcache, enum gdb_signal signal)
570570 {
571571 int ret;
@@ -633,19 +633,24 @@ record_full_message (struct regcache *regcache, enum gdb_signal signal)
633633 record_full_list_release_first ();
634634 else
635635 record_full_insn_num++;
636-
637- return 1;
638636 }
639637
640-static int
638+static bool
641639 record_full_message_wrapper_safe (struct regcache *regcache,
642640 enum gdb_signal signal)
643641 {
644- return catch_errors ([&] ()
645- {
646- return record_full_message (regcache, signal);
647- },
648- "", RETURN_MASK_ALL);
642+ TRY
643+ {
644+ record_full_message (regcache, signal);
645+ }
646+ CATCH (ex, RETURN_MASK_ALL)
647+ {
648+ exception_print (gdb_stderr, ex);
649+ return false;
650+ }
651+ END_CATCH
652+
653+ return true;
649654 }
650655
651656 /* Set to 1 if record_full_store_registers and record_full_xfer_partial
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -760,12 +760,19 @@ update_solib_list (int from_tty)
760760 have not opened a symbol file, we may be able to get its
761761 symbols now! */
762762 if (inf->attach_flag && symfile_objfile == NULL)
763- catch_errors ([&] ()
764- {
765- return ops->open_symbol_file_object (from_tty);
766- },
767- "Error reading attached process's symbol file.\n",
768- RETURN_MASK_ALL);
763+ {
764+ TRY
765+ {
766+ ops->open_symbol_file_object (from_tty);
767+ }
768+ CATCH (ex, RETURN_MASK_ALL)
769+ {
770+ exception_fprintf (gdb_stderr, ex,
771+ "Error reading attached "
772+ "process's symbol file.\n");
773+ }
774+ END_CATCH
775+ }
769776 }
770777
771778 /* GDB and the inferior's dynamic linker each maintain their own
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -54,16 +54,9 @@ FILE *std_err;
5454
5555 static int block_depth (struct block *);
5656
57-struct print_symbol_args
58- {
59- struct gdbarch *gdbarch;
60- struct symbol *symbol;
61- int depth;
62- struct ui_file *outfile;
63- };
64-
65-static int print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
66- int depth, struct ui_file *outfile);
57+static void print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
58+ int depth, struct ui_file *outfile);
59+
6760
6861
6962 void
@@ -358,13 +351,16 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile)
358351 block, not any blocks from included symtabs. */
359352 ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym)
360353 {
361- catch_errors ([&] ()
362- {
363- return print_symbol (gdbarch, sym, depth + 1,
364- outfile);
365- },
366- "Error printing symbol:\n",
367- RETURN_MASK_ERROR);
354+ TRY
355+ {
356+ print_symbol (gdbarch, sym, depth + 1, outfile);
357+ }
358+ CATCH (ex, RETURN_MASK_ERROR)
359+ {
360+ exception_fprintf (gdb_stderr, ex,
361+ "Error printing symbol:\n");
362+ }
363+ END_CATCH
368364 }
369365 }
370366 fprintf_filtered (outfile, "\n");
@@ -515,10 +511,9 @@ maintenance_print_symbols (const char *args, int from_tty)
515511 }
516512 }
517513
518-/* Print symbol SYMBOL on OUTFILE. DEPTH says how far to indent.
519- Returns 0 for error, 1 for success. */
514+/* Print symbol SYMBOL on OUTFILE. DEPTH says how far to indent. */
520515
521-static int
516+static void
522517 print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
523518 int depth, struct ui_file *outfile)
524519 {
@@ -541,7 +536,6 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
541536 section->the_bfd_section));
542537 else
543538 fprintf_filtered (outfile, "\n");
544- return 1;
545539 }
546540 if (SYMBOL_DOMAIN (symbol) == STRUCT_DOMAIN)
547541 {
@@ -689,7 +683,6 @@ print_symbol (struct gdbarch *gdbarch, struct symbol *symbol,
689683 }
690684 }
691685 fprintf_filtered (outfile, "\n");
692- return 1;
693686 }
694687
695688 static void