GNU Binutils with patches for OS216
Revisão | bf4692711232eb96cd840f96d88897a2746d8190 (tree) |
---|---|
Hora | 2017-10-11 00:45:50 |
Autor | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
Eliminate catch_errors
If you want to use catch_errors with a function with parameters, then
currently you have to manually write a "capture" struct wrapping the
arguments and marshall/unmarshall that.
https://sourceware.org/ml/gdb-patches/2017-09/msg00834.html proposed
adjusting catch_errors to use gdb::function_view, which would allow
passing lambdas with automatic captures. However, it seems like using
TRY/CATCH directly instead ends up producing clearer and easier to
debug code. This is what this commit does.
Note that removing catch_errors exposes further cleanup opportunities
around no longer having to follow catch_errors callback type, and also
removes a few cleanups.
I didn't do anything to save/restore current_uiout because I think
that should be the responsibility of the code that changes
current_uiout in the first place.
(Another approach could be to make catch_errors a variadic template
like:
Function &&func, Args... args);
and then with:
calls to the above functions would be wrapped like this:
but I'm thinking that that doesn't improve much if at all either.)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (breakpoint_cond_eval): Change return type to bool
and reverse logic.
(WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE):
No longer macros. Instead ...
(enum wp_check_result): They're now values of this new
enumeration.
(watchpoint_check): Change return type to wp_check_result and
parameter type to bpstat.
(bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors.
(bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of
catch_errors. Reverse logic of watchpoint_check call.
(breakpoint_re_set_one): Now returns void and takes a breakpoint
pointer as parameter.
(breakpoint_re_set): Use TRY/CATCH instead of catch_errors.
* common/common-exceptions.c (throw_exception_sjlj): Update
comments to avoid mentioning catch_errors.
* exceptions.c (catch_errors): Delete.
* exceptions.h: Update comments to avoid mentioning catch_errors.
(catch_errors_ftype, catch_errors): Delete.
* infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors.
(hook_stop_stub): Delete.
(restore_selected_frame): Change return type to void, and
parameter type to const frame_id &.
(restore_infcall_control_state): Use TRY/CATCH instead of
catch_errors.
* main.c (captured_command_loop): Return void and remove
parameter. Remove references to catch_errors.
(captured_main): Use TRY/CATCH instead of catch_errors.
* objc-lang.c (objc_submethod_helper_data)
(find_objc_msgcall_submethod_helper): Delete.
(find_objc_msgcall_submethod): Use TRY/CATCH instead of
catch_errors.
* record-full.c (record_full_message): Return void.
(record_full_message_args, record_full_message_wrapper): Delete.
(record_full_message_wrapper_safe): Return bool and use TRY/CATCH
instead of catch_errors.
* solib-aix.c (solib_aix_open_symbol_file_object): Change
parameter type to int.
* solib-darwin.c (open_symbol_file_object): Ditto.
* solib-dsbt.c (open_symbol_file_object): Ditto.
* solib-frv.c (open_symbol_file_object): Ditto.
* solib-svr4.c (open_symbol_file_object): Ditto.
* solib-target.c (solib_target_open_symbol_file_object): Ditto.
* solib.c (update_solib_list): Use TRY/CATCH instead of
catch_errors.
* solist.h (struct target_so_ops) <open_symbol_file_object>:
Change type.
* symmisc.c (struct print_symbol_args): Remove.
(dump_symtab_1): Use TRY/CATCH instead of catch_errors.
(print_symbol): Change type.
* windows-nat.c (handle_load_dll, handle_unload_dll): Return void
and remove parameters.
(catch_errors): New.
(get_windows_debug_event): Adjust.
gdb/testsuite/ChangeLog:
2017-10-10 Pedro Alves <palves@redhat.com>
* lib/selftest-support.exp (selftest_setup): Update for
captured_command_loop's prototype change.
@@ -1,3 +1,61 @@ | ||
1 | +2017-10-10 Pedro Alves <palves@redhat.com> | |
2 | + Tom Tromey <tom@tromey.com> | |
3 | + | |
4 | + * breakpoint.c (breakpoint_cond_eval): Change return type to bool | |
5 | + and reverse logic. | |
6 | + (WP_DELETED, WP_VALUE_CHANGED, WP_VALUE_NOT_CHANGED, WP_IGNORE): | |
7 | + No longer macros. Instead ... | |
8 | + (enum wp_check_result): They're now values of this new | |
9 | + enumeration. | |
10 | + (watchpoint_check): Change return type to wp_check_result and | |
11 | + parameter type to bpstat. | |
12 | + (bpstat_check_watchpoint): Use TRY/CATCH instead of catch_errors. | |
13 | + (bpstat_check_breakpoint_conditions): Use TRY/CATCH instead of | |
14 | + catch_errors. Reverse logic of watchpoint_check call. | |
15 | + (breakpoint_re_set_one): Now returns void and takes a breakpoint | |
16 | + pointer as parameter. | |
17 | + (breakpoint_re_set): Use TRY/CATCH instead of catch_errors. | |
18 | + * common/common-exceptions.c (throw_exception_sjlj): Update | |
19 | + comments to avoid mentioning catch_errors. | |
20 | + * exceptions.c (catch_errors): Delete. | |
21 | + * exceptions.h: Update comments to avoid mentioning catch_errors. | |
22 | + (catch_errors_ftype, catch_errors): Delete. | |
23 | + * infrun.c (normal_stop): Use TRY/CATCH instead of catch_errors. | |
24 | + (hook_stop_stub): Delete. | |
25 | + (restore_selected_frame): Change return type to void, and | |
26 | + parameter type to const frame_id &. | |
27 | + (restore_infcall_control_state): Use TRY/CATCH instead of | |
28 | + catch_errors. | |
29 | + * main.c (captured_command_loop): Return void and remove | |
30 | + parameter. Remove references to catch_errors. | |
31 | + (captured_main): Use TRY/CATCH instead of catch_errors. | |
32 | + * objc-lang.c (objc_submethod_helper_data) | |
33 | + (find_objc_msgcall_submethod_helper): Delete. | |
34 | + (find_objc_msgcall_submethod): Use TRY/CATCH instead of | |
35 | + catch_errors. | |
36 | + * record-full.c (record_full_message): Return void. | |
37 | + (record_full_message_args, record_full_message_wrapper): Delete. | |
38 | + (record_full_message_wrapper_safe): Return bool and use TRY/CATCH | |
39 | + instead of catch_errors. | |
40 | + * solib-aix.c (solib_aix_open_symbol_file_object): Change | |
41 | + parameter type to int. | |
42 | + * solib-darwin.c (open_symbol_file_object): Ditto. | |
43 | + * solib-dsbt.c (open_symbol_file_object): Ditto. | |
44 | + * solib-frv.c (open_symbol_file_object): Ditto. | |
45 | + * solib-svr4.c (open_symbol_file_object): Ditto. | |
46 | + * solib-target.c (solib_target_open_symbol_file_object): Ditto. | |
47 | + * solib.c (update_solib_list): Use TRY/CATCH instead of | |
48 | + catch_errors. | |
49 | + * solist.h (struct target_so_ops) <open_symbol_file_object>: | |
50 | + Change type. | |
51 | + * symmisc.c (struct print_symbol_args): Remove. | |
52 | + (dump_symtab_1): Use TRY/CATCH instead of catch_errors. | |
53 | + (print_symbol): Change type. | |
54 | + * windows-nat.c (handle_load_dll, handle_unload_dll): Return void | |
55 | + and remove parameters. | |
56 | + (catch_errors): New. | |
57 | + (get_windows_debug_event): Adjust. | |
58 | + | |
1 | 59 | 2017-10-09 Tom Tromey <tom@tromey.com> |
2 | 60 | |
3 | 61 | * mi/mi-main.c (free_splay_tree): Remove. |
@@ -103,8 +103,6 @@ static void map_breakpoint_numbers (const char *, | ||
103 | 103 | |
104 | 104 | static void ignore_command (char *, int); |
105 | 105 | |
106 | -static int breakpoint_re_set_one (void *); | |
107 | - | |
108 | 106 | static void breakpoint_re_set_default (struct breakpoint *); |
109 | 107 | |
110 | 108 | static void |
@@ -178,8 +176,6 @@ static void info_breakpoints_command (char *, int); | ||
178 | 176 | |
179 | 177 | static void info_watchpoints_command (char *, int); |
180 | 178 | |
181 | -static int breakpoint_cond_eval (void *); | |
182 | - | |
183 | 179 | static void cleanup_executing_breakpoints (void *); |
184 | 180 | |
185 | 181 | static void commands_command (char *, int); |
@@ -191,8 +187,6 @@ static int remove_breakpoint_1 (struct bp_location *, enum remove_bp_reason); | ||
191 | 187 | |
192 | 188 | static enum print_stop_action print_bp_stop_message (bpstat bs); |
193 | 189 | |
194 | -static int watchpoint_check (void *); | |
195 | - | |
196 | 190 | static int hw_breakpoint_used_count (void); |
197 | 191 | |
198 | 192 | static int hw_watchpoint_use_count (struct breakpoint *); |
@@ -4842,21 +4836,16 @@ bpstat_print (bpstat bs, int kind) | ||
4842 | 4836 | return PRINT_UNKNOWN; |
4843 | 4837 | } |
4844 | 4838 | |
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. */ | |
4851 | 4840 | |
4852 | -static int | |
4853 | -breakpoint_cond_eval (void *exp) | |
4841 | +static bool | |
4842 | +breakpoint_cond_eval (expression *exp) | |
4854 | 4843 | { |
4855 | 4844 | struct value *mark = value_mark (); |
4856 | - int i = !value_true (evaluate_expression ((struct expression *) exp)); | |
4845 | + bool res = value_true (evaluate_expression (exp)); | |
4857 | 4846 | |
4858 | 4847 | value_free_to_mark (mark); |
4859 | - return i; | |
4848 | + return res; | |
4860 | 4849 | } |
4861 | 4850 | |
4862 | 4851 | /* Allocate a new bpstat. Link it to the FIFO list by BS_LINK_POINTER. */ |
@@ -4966,30 +4955,31 @@ watchpoints_triggered (struct target_waitstatus *ws) | ||
4966 | 4955 | return 1; |
4967 | 4956 | } |
4968 | 4957 | |
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 | + | |
4964 | + /* The value has changed. */ | |
4965 | + WP_VALUE_CHANGED = 2, | |
4966 | + | |
4967 | + /* The value has not changed. */ | |
4968 | + WP_VALUE_NOT_CHANGED = 3, | |
4969 | + | |
4970 | + /* Ignore this watchpoint, no matter if the value changed or not. */ | |
4971 | + WP_IGNORE = 4, | |
4972 | + }; | |
4979 | 4973 | |
4980 | 4974 | #define BP_TEMPFLAG 1 |
4981 | 4975 | #define BP_HARDWAREFLAG 2 |
4982 | 4976 | |
4983 | 4977 | /* 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. */ | |
4978 | + changed. */ | |
4988 | 4979 | |
4989 | -static int | |
4990 | -watchpoint_check (void *p) | |
4980 | +static wp_check_result | |
4981 | +watchpoint_check (bpstat bs) | |
4991 | 4982 | { |
4992 | - bpstat bs = (bpstat) p; | |
4993 | 4983 | struct watchpoint *b; |
4994 | 4984 | struct frame_info *fr; |
4995 | 4985 | int within_current_scope; |
@@ -5185,13 +5175,29 @@ bpstat_check_watchpoint (bpstat bs) | ||
5185 | 5175 | |
5186 | 5176 | if (must_check_value) |
5187 | 5177 | { |
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 (watchpoint_check, bs, message, | |
5193 | - RETURN_MASK_ALL); | |
5194 | - do_cleanups (cleanups); | |
5178 | + wp_check_result e; | |
5179 | + | |
5180 | + TRY | |
5181 | + { | |
5182 | + e = watchpoint_check (bs); | |
5183 | + } | |
5184 | + CATCH (ex, RETURN_MASK_ALL) | |
5185 | + { | |
5186 | + exception_fprintf (gdb_stderr, ex, | |
5187 | + "Error evaluating expression " | |
5188 | + "for watchpoint %d\n", | |
5189 | + b->number); | |
5190 | + | |
5191 | + SWITCH_THRU_ALL_UIS () | |
5192 | + { | |
5193 | + printf_filtered (_("Watchpoint %d deleted.\n"), | |
5194 | + b->number); | |
5195 | + } | |
5196 | + watchpoint_del_at_next_stop (b); | |
5197 | + e = WP_DELETED; | |
5198 | + } | |
5199 | + END_CATCH | |
5200 | + | |
5195 | 5201 | switch (e) |
5196 | 5202 | { |
5197 | 5203 | case WP_DELETED: |
@@ -5287,18 +5293,6 @@ bpstat_check_watchpoint (bpstat bs) | ||
5287 | 5293 | break; |
5288 | 5294 | default: |
5289 | 5295 | /* Can't happen. */ |
5290 | - case 0: | |
5291 | - /* Error from catch_errors. */ | |
5292 | - { | |
5293 | - SWITCH_THRU_ALL_UIS () | |
5294 | - { | |
5295 | - printf_filtered (_("Watchpoint %d deleted.\n"), | |
5296 | - b->number); | |
5297 | - } | |
5298 | - watchpoint_del_at_next_stop (b); | |
5299 | - /* We've already printed what needs to be printed. */ | |
5300 | - bs->print_it = print_it_done; | |
5301 | - } | |
5302 | 5296 | break; |
5303 | 5297 | } |
5304 | 5298 | } |
@@ -5324,7 +5318,8 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid) | ||
5324 | 5318 | { |
5325 | 5319 | const struct bp_location *bl; |
5326 | 5320 | struct breakpoint *b; |
5327 | - int value_is_zero = 0; | |
5321 | + /* Assume stop. */ | |
5322 | + bool condition_result = true; | |
5328 | 5323 | struct expression *cond; |
5329 | 5324 | |
5330 | 5325 | gdb_assert (bs->stop); |
@@ -5420,23 +5415,30 @@ bpstat_check_breakpoint_conditions (bpstat bs, ptid_t ptid) | ||
5420 | 5415 | within_current_scope = 0; |
5421 | 5416 | } |
5422 | 5417 | if (within_current_scope) |
5423 | - value_is_zero | |
5424 | - = catch_errors (breakpoint_cond_eval, cond, | |
5425 | - "Error in testing breakpoint condition:\n", | |
5426 | - RETURN_MASK_ALL); | |
5418 | + { | |
5419 | + TRY | |
5420 | + { | |
5421 | + condition_result = breakpoint_cond_eval (cond); | |
5422 | + } | |
5423 | + CATCH (ex, RETURN_MASK_ALL) | |
5424 | + { | |
5425 | + exception_fprintf (gdb_stderr, ex, | |
5426 | + "Error in testing breakpoint condition:\n"); | |
5427 | + } | |
5428 | + END_CATCH | |
5429 | + } | |
5427 | 5430 | else |
5428 | 5431 | { |
5429 | 5432 | warning (_("Watchpoint condition cannot be tested " |
5430 | 5433 | "in the current scope")); |
5431 | 5434 | /* If we failed to set the right context for this |
5432 | 5435 | watchpoint, unconditionally report it. */ |
5433 | - value_is_zero = 0; | |
5434 | 5436 | } |
5435 | 5437 | /* FIXME-someday, should give breakpoint #. */ |
5436 | 5438 | value_free_to_mark (mark); |
5437 | 5439 | } |
5438 | 5440 | |
5439 | - if (cond && value_is_zero) | |
5441 | + if (cond && !condition_result) | |
5440 | 5442 | { |
5441 | 5443 | bs->stop = 0; |
5442 | 5444 | } |
@@ -14148,21 +14150,16 @@ prepare_re_set_context (struct breakpoint *b) | ||
14148 | 14150 | return make_cleanup (null_cleanup, NULL); |
14149 | 14151 | } |
14150 | 14152 | |
14151 | -/* Reset a breakpoint given it's struct breakpoint * BINT. | |
14152 | - The value we return ends up being the return value from catch_errors. | |
14153 | - Unused in this case. */ | |
14153 | +/* Reset a breakpoint. */ | |
14154 | 14154 | |
14155 | -static int | |
14156 | -breakpoint_re_set_one (void *bint) | |
14155 | +static void | |
14156 | +breakpoint_re_set_one (breakpoint *b) | |
14157 | 14157 | { |
14158 | - /* Get past catch_errs. */ | |
14159 | - struct breakpoint *b = (struct breakpoint *) bint; | |
14160 | 14158 | struct cleanup *cleanups; |
14161 | 14159 | |
14162 | 14160 | cleanups = prepare_re_set_context (b); |
14163 | 14161 | b->ops->re_set (b); |
14164 | 14162 | do_cleanups (cleanups); |
14165 | - return 0; | |
14166 | 14163 | } |
14167 | 14164 | |
14168 | 14165 | /* Re-set breakpoint locations for the current program space. |
@@ -14188,12 +14185,17 @@ breakpoint_re_set (void) | ||
14188 | 14185 | |
14189 | 14186 | ALL_BREAKPOINTS_SAFE (b, b_tmp) |
14190 | 14187 | { |
14191 | - /* Format possible error msg. */ | |
14192 | - char *message = xstrprintf ("Error in re-setting breakpoint %d: ", | |
14193 | - b->number); | |
14194 | - struct cleanup *cleanups = make_cleanup (xfree, message); | |
14195 | - catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL); | |
14196 | - do_cleanups (cleanups); | |
14188 | + TRY | |
14189 | + { | |
14190 | + breakpoint_re_set_one (b); | |
14191 | + } | |
14192 | + CATCH (ex, RETURN_MASK_ALL) | |
14193 | + { | |
14194 | + exception_fprintf (gdb_stderr, ex, | |
14195 | + "Error in re-setting breakpoint %d: ", | |
14196 | + b->number); | |
14197 | + } | |
14198 | + END_CATCH | |
14197 | 14199 | } |
14198 | 14200 | set_language (save_language); |
14199 | 14201 | input_radix = save_input_radix; |
@@ -264,16 +264,16 @@ gdb_exception_sliced_copy (struct gdb_exception *to, const struct gdb_exception | ||
264 | 264 | |
265 | 265 | #endif /* !GDB_XCPT_SJMP */ |
266 | 266 | |
267 | -/* Return EXCEPTION to the nearest containing catch_errors(). */ | |
267 | +/* Return EXCEPTION to the nearest containing CATCH_SJLJ block. */ | |
268 | 268 | |
269 | 269 | void |
270 | 270 | throw_exception_sjlj (struct gdb_exception exception) |
271 | 271 | { |
272 | 272 | do_cleanups (all_cleanups ()); |
273 | 273 | |
274 | - /* Jump to the containing catch_errors() call, communicating REASON | |
275 | - to that call via setjmp's return value. Note that REASON can't | |
276 | - be zero, by definition in defs.h. */ | |
274 | + /* Jump to the nearest CATCH_SJLJ block, communicating REASON to | |
275 | + that call via setjmp's return value. Note that REASON can't be | |
276 | + zero, by definition in common-exceptions.h. */ | |
277 | 277 | exceptions_state_mc (CATCH_THROWING); |
278 | 278 | current_catcher->exception = exception; |
279 | 279 | longjmp (current_catcher->buf, exception.reason); |
@@ -217,45 +217,6 @@ catch_exceptions_with_msg (struct ui_out *func_uiout, | ||
217 | 217 | return val; |
218 | 218 | } |
219 | 219 | |
220 | -/* This function is superseded by catch_exceptions(). */ | |
221 | - | |
222 | -int | |
223 | -catch_errors (catch_errors_ftype *func, void *func_args, | |
224 | - const char *errstring, return_mask mask) | |
225 | -{ | |
226 | - struct gdb_exception exception = exception_none; | |
227 | - volatile int val = 0; | |
228 | - struct ui_out *saved_uiout; | |
229 | - | |
230 | - /* Save the global ``struct ui_out'' builder. */ | |
231 | - saved_uiout = current_uiout; | |
232 | - | |
233 | - TRY | |
234 | - { | |
235 | - val = func (func_args); | |
236 | - } | |
237 | - CATCH (ex, RETURN_MASK_ALL) | |
238 | - { | |
239 | - exception = ex; | |
240 | - } | |
241 | - END_CATCH | |
242 | - | |
243 | - /* Restore the global builder. */ | |
244 | - current_uiout = saved_uiout; | |
245 | - | |
246 | - if (exception.reason < 0 && (mask & RETURN_MASK (exception.reason)) == 0) | |
247 | - { | |
248 | - /* The caller didn't request that the event be caught. | |
249 | - Rethrow. */ | |
250 | - throw_exception (exception); | |
251 | - } | |
252 | - | |
253 | - exception_fprintf (gdb_stderr, exception, "%s", errstring); | |
254 | - if (exception.reason != 0) | |
255 | - return 0; | |
256 | - return val; | |
257 | -} | |
258 | - | |
259 | 220 | /* See exceptions.h. */ |
260 | 221 | |
261 | 222 | int |
@@ -48,21 +48,16 @@ extern void exception_fprintf (struct ui_file *file, struct gdb_exception e, | ||
48 | 48 | copy of the gdb error message. This is used when a silent error is |
49 | 49 | issued and the caller wants to manually issue the error message. |
50 | 50 | |
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 | |
58 | 57 | fairly quickly, even if some further processing is being done. |
59 | 58 | |
60 | 59 | 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. */ | |
66 | 61 | |
67 | 62 | struct ui_out; |
68 | 63 | typedef int (catch_exceptions_ftype) (struct ui_out *ui_out, void *args); |
@@ -76,19 +71,6 @@ extern int catch_exceptions_with_msg (struct ui_out *uiout, | ||
76 | 71 | char **gdberrmsg, |
77 | 72 | return_mask mask); |
78 | 73 | |
79 | -/* If CATCH_ERRORS_FTYPE throws an error, catch_errors() returns zero | |
80 | - otherwize the result from CATCH_ERRORS_FTYPE is returned. It is | |
81 | - probably useful for CATCH_ERRORS_FTYPE to always return a non-zero | |
82 | - value. It's unfortunate that, catch_errors() does not return an | |
83 | - indication of the exact exception that it caught - quit_flag might | |
84 | - help. | |
85 | - | |
86 | - This function is superseded by catch_exceptions(). */ | |
87 | - | |
88 | -typedef int (catch_errors_ftype) (void *); | |
89 | -extern int catch_errors (catch_errors_ftype *, void *, | |
90 | - const char *, return_mask); | |
91 | - | |
92 | 74 | /* Compare two exception objects for print equality. */ |
93 | 75 | extern int exception_print_same (struct gdb_exception e1, |
94 | 76 | struct gdb_exception e2); |
@@ -80,10 +80,6 @@ static void sig_print_header (void); | ||
80 | 80 | |
81 | 81 | static void resume_cleanups (void *); |
82 | 82 | |
83 | -static int hook_stop_stub (void *); | |
84 | - | |
85 | -static int restore_selected_frame (void *); | |
86 | - | |
87 | 83 | static int follow_fork (void); |
88 | 84 | |
89 | 85 | static int follow_fork_inferior (int follow_child, int detach_fork); |
@@ -8314,8 +8310,16 @@ normal_stop (void) | ||
8314 | 8310 | struct cleanup *old_chain |
8315 | 8311 | = make_cleanup (release_stop_context_cleanup, saved_context); |
8316 | 8312 | |
8317 | - catch_errors (hook_stop_stub, stop_command, | |
8318 | - "Error while running hook_stop:\n", RETURN_MASK_ALL); | |
8313 | + TRY | |
8314 | + { | |
8315 | + execute_cmd_pre_hook (stop_command); | |
8316 | + } | |
8317 | + CATCH (ex, RETURN_MASK_ALL) | |
8318 | + { | |
8319 | + exception_fprintf (gdb_stderr, ex, | |
8320 | + "Error while running hook_stop:\n"); | |
8321 | + } | |
8322 | + END_CATCH | |
8319 | 8323 | |
8320 | 8324 | /* If the stop hook resumes the target, then there's no point in |
8321 | 8325 | trying to notify about the previous stop; its context is |
@@ -8356,13 +8360,6 @@ normal_stop (void) | ||
8356 | 8360 | |
8357 | 8361 | return 0; |
8358 | 8362 | } |
8359 | - | |
8360 | -static int | |
8361 | -hook_stop_stub (void *cmd) | |
8362 | -{ | |
8363 | - execute_cmd_pre_hook ((struct cmd_list_element *) cmd); | |
8364 | - return (0); | |
8365 | -} | |
8366 | 8363 | |
8367 | 8364 | int |
8368 | 8365 | signal_stop_state (int signo) |
@@ -8983,25 +8980,20 @@ save_infcall_control_state (void) | ||
8983 | 8980 | return inf_status; |
8984 | 8981 | } |
8985 | 8982 | |
8986 | -static int | |
8987 | -restore_selected_frame (void *args) | |
8983 | +static void | |
8984 | +restore_selected_frame (const frame_id &fid) | |
8988 | 8985 | { |
8989 | - struct frame_id *fid = (struct frame_id *) args; | |
8990 | - struct frame_info *frame; | |
8991 | - | |
8992 | - frame = frame_find_by_id (*fid); | |
8986 | + frame_info *frame = frame_find_by_id (fid); | |
8993 | 8987 | |
8994 | 8988 | /* If inf_status->selected_frame_id is NULL, there was no previously |
8995 | 8989 | selected frame. */ |
8996 | 8990 | if (frame == NULL) |
8997 | 8991 | { |
8998 | 8992 | warning (_("Unable to restore previously selected frame.")); |
8999 | - return 0; | |
8993 | + return; | |
9000 | 8994 | } |
9001 | 8995 | |
9002 | 8996 | select_frame (frame); |
9003 | - | |
9004 | - return (1); | |
9005 | 8997 | } |
9006 | 8998 | |
9007 | 8999 | /* Restore inferior session state to INF_STATUS. */ |
@@ -9031,16 +9023,22 @@ restore_infcall_control_state (struct infcall_control_state *inf_status) | ||
9031 | 9023 | |
9032 | 9024 | if (target_has_stack) |
9033 | 9025 | { |
9034 | - /* The point of catch_errors is that if the stack is clobbered, | |
9026 | + /* The point of the try/catch is that if the stack is clobbered, | |
9035 | 9027 | walking the stack might encounter a garbage pointer and |
9036 | 9028 | error() trying to dereference it. */ |
9037 | - if (catch_errors | |
9038 | - (restore_selected_frame, &inf_status->selected_frame_id, | |
9039 | - "Unable to restore previously selected frame:\n", | |
9040 | - RETURN_MASK_ERROR) == 0) | |
9041 | - /* Error in restoring the selected frame. Select the innermost | |
9042 | - frame. */ | |
9043 | - select_frame (get_current_frame ()); | |
9029 | + TRY | |
9030 | + { | |
9031 | + restore_selected_frame (inf_status->selected_frame_id); | |
9032 | + } | |
9033 | + CATCH (ex, RETURN_MASK_ERROR) | |
9034 | + { | |
9035 | + exception_fprintf (gdb_stderr, ex, | |
9036 | + "Unable to restore previously selected frame:\n"); | |
9037 | + /* Error in restoring the selected frame. Select the | |
9038 | + innermost frame. */ | |
9039 | + select_frame (get_current_frame ()); | |
9040 | + } | |
9041 | + END_CATCH | |
9044 | 9042 | } |
9045 | 9043 | |
9046 | 9044 | xfree (inf_status); |
@@ -305,11 +305,10 @@ setup_alternate_signal_stack (void) | ||
305 | 305 | #endif |
306 | 306 | } |
307 | 307 | |
308 | -/* Call command_loop. If it happens to return, pass that through as a | |
309 | - non-zero return status. */ | |
308 | +/* Call command_loop. */ | |
310 | 309 | |
311 | -static int | |
312 | -captured_command_loop (void *data) | |
310 | +static void | |
311 | +captured_command_loop () | |
313 | 312 | { |
314 | 313 | struct ui *ui = current_ui; |
315 | 314 |
@@ -333,11 +332,9 @@ captured_command_loop (void *data) | ||
333 | 332 | check to detect bad FUNCs code. */ |
334 | 333 | do_cleanups (all_cleanups ()); |
335 | 334 | /* If the command_loop returned, normally (rather than threw an |
336 | - error) we try to quit. If the quit is aborted, catch_errors() | |
337 | - which called this catch the signal and restart the command | |
338 | - loop. */ | |
335 | + error) we try to quit. If the quit is aborted, our caller | |
336 | + catches the signal and restarts the command loop. */ | |
339 | 337 | quit_command (NULL, ui->instream == ui->stdin_stream); |
340 | - return 1; | |
341 | 338 | } |
342 | 339 | |
343 | 340 | /* Handle command errors thrown from within catch_command_errors. */ |
@@ -1145,7 +1142,15 @@ captured_main (void *data) | ||
1145 | 1142 | change - SET_TOP_LEVEL() - has been eliminated. */ |
1146 | 1143 | while (1) |
1147 | 1144 | { |
1148 | - catch_errors (captured_command_loop, 0, "", RETURN_MASK_ALL); | |
1145 | + TRY | |
1146 | + { | |
1147 | + captured_command_loop (); | |
1148 | + } | |
1149 | + CATCH (ex, RETURN_MASK_ALL) | |
1150 | + { | |
1151 | + exception_print (gdb_stderr, ex); | |
1152 | + } | |
1153 | + END_CATCH | |
1149 | 1154 | } |
1150 | 1155 | /* No exit -- exit is through quit_command. */ |
1151 | 1156 | } |
@@ -1310,43 +1310,25 @@ find_objc_msgsend (void) | ||
1310 | 1310 | * dependent modules. |
1311 | 1311 | */ |
1312 | 1312 | |
1313 | -struct objc_submethod_helper_data { | |
1314 | - int (*f) (CORE_ADDR, CORE_ADDR *); | |
1315 | - CORE_ADDR pc; | |
1316 | - CORE_ADDR *new_pc; | |
1317 | -}; | |
1318 | - | |
1319 | -static int | |
1320 | -find_objc_msgcall_submethod_helper (void * arg) | |
1321 | -{ | |
1322 | - struct objc_submethod_helper_data *s = | |
1323 | - (struct objc_submethod_helper_data *) arg; | |
1324 | - | |
1325 | - if (s->f (s->pc, s->new_pc) == 0) | |
1326 | - return 1; | |
1327 | - else | |
1328 | - return 0; | |
1329 | -} | |
1330 | - | |
1331 | 1313 | static int |
1332 | 1314 | find_objc_msgcall_submethod (int (*f) (CORE_ADDR, CORE_ADDR *), |
1333 | 1315 | CORE_ADDR pc, |
1334 | 1316 | CORE_ADDR *new_pc) |
1335 | 1317 | { |
1336 | - struct objc_submethod_helper_data s; | |
1337 | - | |
1338 | - s.f = f; | |
1339 | - s.pc = pc; | |
1340 | - s.new_pc = new_pc; | |
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 | + END_CATCH | |
1341 | 1330 | |
1342 | - if (catch_errors (find_objc_msgcall_submethod_helper, | |
1343 | - (void *) &s, | |
1344 | - "Unable to determine target of " | |
1345 | - "Objective-C method call (ignoring):\n", | |
1346 | - RETURN_MASK_ALL) == 0) | |
1347 | - return 1; | |
1348 | - else | |
1349 | - return 0; | |
1331 | + return 0; | |
1350 | 1332 | } |
1351 | 1333 | |
1352 | 1334 | int |
@@ -565,7 +565,7 @@ record_full_arch_list_cleanups (void *ignore) | ||
565 | 565 | record the running message of inferior and set them to |
566 | 566 | record_full_arch_list, and add it to record_full_list. */ |
567 | 567 | |
568 | -static int | |
568 | +static void | |
569 | 569 | record_full_message (struct regcache *regcache, enum gdb_signal signal) |
570 | 570 | { |
571 | 571 | int ret; |
@@ -633,36 +633,24 @@ record_full_message (struct regcache *regcache, enum gdb_signal signal) | ||
633 | 633 | record_full_list_release_first (); |
634 | 634 | else |
635 | 635 | record_full_insn_num++; |
636 | - | |
637 | - return 1; | |
638 | -} | |
639 | - | |
640 | -struct record_full_message_args { | |
641 | - struct regcache *regcache; | |
642 | - enum gdb_signal signal; | |
643 | -}; | |
644 | - | |
645 | -static int | |
646 | -record_full_message_wrapper (void *args) | |
647 | -{ | |
648 | - struct record_full_message_args *record_full_args | |
649 | - = (struct record_full_message_args *) args; | |
650 | - | |
651 | - return record_full_message (record_full_args->regcache, | |
652 | - record_full_args->signal); | |
653 | 636 | } |
654 | 637 | |
655 | -static int | |
638 | +static bool | |
656 | 639 | record_full_message_wrapper_safe (struct regcache *regcache, |
657 | 640 | enum gdb_signal signal) |
658 | 641 | { |
659 | - struct record_full_message_args args; | |
660 | - | |
661 | - args.regcache = regcache; | |
662 | - args.signal = signal; | |
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 | |
663 | 652 | |
664 | - return catch_errors (record_full_message_wrapper, &args, "", | |
665 | - RETURN_MASK_ALL); | |
653 | + return true; | |
666 | 654 | } |
667 | 655 | |
668 | 656 | /* Set to 1 if record_full_store_registers and record_full_xfer_partial |
@@ -589,7 +589,7 @@ solib_aix_current_sos (void) | ||
589 | 589 | /* Implement the "open_symbol_file_object" target_so_ops method. */ |
590 | 590 | |
591 | 591 | static int |
592 | -solib_aix_open_symbol_file_object (void *from_ttyp) | |
592 | +solib_aix_open_symbol_file_object (int from_tty) | |
593 | 593 | { |
594 | 594 | return 0; |
595 | 595 | } |
@@ -222,7 +222,7 @@ find_program_interpreter (void) | ||
222 | 222 | Note that darwin-nat.c implements pid_to_exec_file. */ |
223 | 223 | |
224 | 224 | static int |
225 | -open_symbol_file_object (void *from_ttyp) | |
225 | +open_symbol_file_object (int from_tty) | |
226 | 226 | { |
227 | 227 | return 0; |
228 | 228 | } |
@@ -507,16 +507,10 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr) | ||
507 | 507 | return 0; |
508 | 508 | } |
509 | 509 | |
510 | -/* If no open symbol file, attempt to locate and open the main symbol | |
511 | - file. | |
512 | - | |
513 | - If FROM_TTYP dereferences to a non-zero integer, allow messages to | |
514 | - be printed. This parameter is a pointer rather than an int because | |
515 | - open_symbol_file_object is called via catch_errors and | |
516 | - catch_errors requires a pointer argument. */ | |
510 | +/* See solist.h. */ | |
517 | 511 | |
518 | 512 | static int |
519 | -open_symbol_file_object (void *from_ttyp) | |
513 | +open_symbol_file_object (int from_tty) | |
520 | 514 | { |
521 | 515 | /* Unimplemented. */ |
522 | 516 | return 0; |
@@ -246,7 +246,7 @@ static int enable_break2 (void); | ||
246 | 246 | /* Implement the "open_symbol_file_object" target_so_ops method. */ |
247 | 247 | |
248 | 248 | static int |
249 | -open_symbol_file_object (void *from_ttyp) | |
249 | +open_symbol_file_object (int from_tty) | |
250 | 250 | { |
251 | 251 | /* Unimplemented. */ |
252 | 252 | return 0; |
@@ -984,20 +984,14 @@ svr4_keep_data_in_core (CORE_ADDR vaddr, unsigned long size) | ||
984 | 984 | return (name_lm >= vaddr && name_lm < vaddr + size); |
985 | 985 | } |
986 | 986 | |
987 | -/* Implement the "open_symbol_file_object" target_so_ops method. | |
988 | - | |
989 | - If no open symbol file, attempt to locate and open the main symbol | |
990 | - file. On SVR4 systems, this is the first link map entry. If its | |
991 | - name is here, we can open it. Useful when attaching to a process | |
992 | - without first loading its symbol file. */ | |
987 | +/* See solist.h. */ | |
993 | 988 | |
994 | 989 | static int |
995 | -open_symbol_file_object (void *from_ttyp) | |
990 | +open_symbol_file_object (int from_tty) | |
996 | 991 | { |
997 | 992 | CORE_ADDR lm, l_name; |
998 | 993 | char *filename; |
999 | 994 | int errcode; |
1000 | - int from_tty = *(int *)from_ttyp; | |
1001 | 995 | struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); |
1002 | 996 | struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; |
1003 | 997 | int l_name_size = TYPE_LENGTH (ptr_type); |
@@ -452,7 +452,7 @@ Could not relocate shared library \"%s\": bad offsets"), so->so_name); | ||
452 | 452 | } |
453 | 453 | |
454 | 454 | static int |
455 | -solib_target_open_symbol_file_object (void *from_ttyp) | |
455 | +solib_target_open_symbol_file_object (int from_tty) | |
456 | 456 | { |
457 | 457 | /* We can't locate the main symbol file based on the target's |
458 | 458 | knowledge; the user has to specify it. */ |
@@ -760,9 +760,19 @@ update_solib_list (int from_tty) | ||
760 | 760 | have not opened a symbol file, we may be able to get its |
761 | 761 | symbols now! */ |
762 | 762 | if (inf->attach_flag && symfile_objfile == NULL) |
763 | - catch_errors (ops->open_symbol_file_object, &from_tty, | |
764 | - "Error reading attached process's symbol file.\n", | |
765 | - 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 | + } | |
766 | 776 | } |
767 | 777 | |
768 | 778 | /* GDB and the inferior's dynamic linker each maintain their own |
@@ -121,11 +121,8 @@ struct target_so_ops | ||
121 | 121 | struct so_list *(*current_sos) (void); |
122 | 122 | |
123 | 123 | /* Find, open, and read the symbols for the main executable. If |
124 | - FROM_TTYP dereferences to a non-zero integer, allow messages to | |
125 | - be printed. This parameter is a pointer rather than an int | |
126 | - because open_symbol_file_object is called via catch_errors and | |
127 | - catch_errors requires a pointer argument. */ | |
128 | - int (*open_symbol_file_object) (void *from_ttyp); | |
124 | + FROM_TTY is non-zero, allow messages to be printed. */ | |
125 | + int (*open_symbol_file_object) (int from_ttyp); | |
129 | 126 | |
130 | 127 | /* Determine if PC lies in the dynamic symbol resolution code of |
131 | 128 | the run time loader. */ |
@@ -54,15 +54,8 @@ FILE *std_err; | ||
54 | 54 | |
55 | 55 | static int block_depth (struct block *); |
56 | 56 | |
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 (void *); | |
57 | +static void print_symbol (struct gdbarch *gdbarch, struct symbol *symbol, | |
58 | + int depth, ui_file *outfile); | |
66 | 59 | |
67 | 60 | |
68 | 61 | void |
@@ -357,14 +350,16 @@ dump_symtab_1 (struct symtab *symtab, struct ui_file *outfile) | ||
357 | 350 | block, not any blocks from included symtabs. */ |
358 | 351 | ALL_DICT_SYMBOLS (BLOCK_DICT (b), iter, sym) |
359 | 352 | { |
360 | - struct print_symbol_args s; | |
361 | - | |
362 | - s.gdbarch = gdbarch; | |
363 | - s.symbol = sym; | |
364 | - s.depth = depth + 1; | |
365 | - s.outfile = outfile; | |
366 | - catch_errors (print_symbol, &s, "Error printing symbol:\n", | |
367 | - RETURN_MASK_ERROR); | |
353 | + TRY | |
354 | + { | |
355 | + print_symbol (gdbarch, sym, depth + 1, outfile); | |
356 | + } | |
357 | + CATCH (ex, RETURN_MASK_ERROR) | |
358 | + { | |
359 | + exception_fprintf (gdb_stderr, ex, | |
360 | + "Error printing symbol:\n"); | |
361 | + } | |
362 | + END_CATCH | |
368 | 363 | } |
369 | 364 | } |
370 | 365 | fprintf_filtered (outfile, "\n"); |
@@ -515,18 +510,12 @@ maintenance_print_symbols (const char *args, int from_tty) | ||
515 | 510 | } |
516 | 511 | } |
517 | 512 | |
518 | -/* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how | |
519 | - far to indent. ARGS is really a struct print_symbol_args *, but is | |
520 | - declared as char * to get it past catch_errors. Returns 0 for error, | |
521 | - 1 for success. */ | |
513 | +/* Print symbol SYMBOL on OUTFILE. DEPTH says how far to indent. */ | |
522 | 514 | |
523 | -static int | |
524 | -print_symbol (void *args) | |
515 | +static void | |
516 | +print_symbol (struct gdbarch *gdbarch, struct symbol *symbol, | |
517 | + int depth, ui_file *outfile) | |
525 | 518 | { |
526 | - struct gdbarch *gdbarch = ((struct print_symbol_args *) args)->gdbarch; | |
527 | - struct symbol *symbol = ((struct print_symbol_args *) args)->symbol; | |
528 | - int depth = ((struct print_symbol_args *) args)->depth; | |
529 | - struct ui_file *outfile = ((struct print_symbol_args *) args)->outfile; | |
530 | 519 | struct obj_section *section; |
531 | 520 | |
532 | 521 | if (SYMBOL_OBJFILE_OWNED (symbol)) |
@@ -546,8 +535,9 @@ print_symbol (void *args) | ||
546 | 535 | section->the_bfd_section)); |
547 | 536 | else |
548 | 537 | fprintf_filtered (outfile, "\n"); |
549 | - return 1; | |
538 | + return; | |
550 | 539 | } |
540 | + | |
551 | 541 | if (SYMBOL_DOMAIN (symbol) == STRUCT_DOMAIN) |
552 | 542 | { |
553 | 543 | if (TYPE_TAG_NAME (SYMBOL_TYPE (symbol))) |
@@ -694,7 +684,6 @@ print_symbol (void *args) | ||
694 | 684 | } |
695 | 685 | } |
696 | 686 | fprintf_filtered (outfile, "\n"); |
697 | - return 1; | |
698 | 687 | } |
699 | 688 | |
700 | 689 | static void |
@@ -1,3 +1,8 @@ | ||
1 | +2017-10-10 Pedro Alves <palves@redhat.com> | |
2 | + | |
3 | + * lib/selftest-support.exp (selftest_setup): Update for | |
4 | + captured_command_loop's prototype change. | |
5 | + | |
1 | 6 | 2017-10-09 Pedro Alves <palves@redhat.com> |
2 | 7 | |
3 | 8 | Test both arch1=>arch2 and arch2=>arch1. |
@@ -88,10 +88,10 @@ proc selftest_setup { executable function } { | ||
88 | 88 | |
89 | 89 | set description "run until breakpoint at $function" |
90 | 90 | gdb_test_multiple "run $INTERNAL_GDBFLAGS" "$description" { |
91 | - -re "Starting program.*Breakpoint \[0-9\]+,.*$function .data.* at .*main.c:.*$gdb_prompt $" { | |
91 | + -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(\\).* at .*main.c:.*$gdb_prompt $" { | |
92 | 92 | pass "$description" |
93 | 93 | } |
94 | - -re "Starting program.*Breakpoint \[0-9\]+,.*$function .data.*$gdb_prompt $" { | |
94 | + -re "Starting program.*Breakpoint \[0-9\]+,.*$function \\(\\).*$gdb_prompt $" { | |
95 | 95 | xfail "$description (line numbers scrambled?)" |
96 | 96 | } |
97 | 97 | -re "Starting program.*Breakpoint \[0-9\]+,.* at .*main.c:.*$function.*$gdb_prompt $" { |
@@ -756,8 +756,8 @@ get_image_name (HANDLE h, void *address, int unicode) | ||
756 | 756 | do_initial_windows_stuff and windows_add_all_dlls for more info |
757 | 757 | on how we handle DLL loading during that phase). */ |
758 | 758 | |
759 | -static int | |
760 | -handle_load_dll (void *dummy) | |
759 | +static void | |
760 | +handle_load_dll () | |
761 | 761 | { |
762 | 762 | LOAD_DLL_DEBUG_INFO *event = ¤t_event.u.LoadDll; |
763 | 763 | char *dll_name; |
@@ -770,7 +770,7 @@ handle_load_dll (void *dummy) | ||
770 | 770 | dll_name = get_image_name (current_process_handle, |
771 | 771 | event->lpImageName, event->fUnicode); |
772 | 772 | if (!dll_name) |
773 | - return 1; | |
773 | + return; | |
774 | 774 | |
775 | 775 | solib_end->next = windows_make_so (dll_name, event->lpBaseOfDll); |
776 | 776 | solib_end = solib_end->next; |
@@ -779,8 +779,6 @@ handle_load_dll (void *dummy) | ||
779 | 779 | |
780 | 780 | DEBUG_EVENTS (("gdb: Loading dll \"%s\" at %s.\n", solib_end->so_name, |
781 | 781 | host_address_to_string (li->load_addr))); |
782 | - | |
783 | - return 1; | |
784 | 782 | } |
785 | 783 | |
786 | 784 | static void |
@@ -800,8 +798,8 @@ windows_free_so (struct so_list *so) | ||
800 | 798 | do_initial_windows_stuff and windows_add_all_dlls for more info |
801 | 799 | on how we handle DLL loading during that phase). */ |
802 | 800 | |
803 | -static int | |
804 | -handle_unload_dll (void *dummy) | |
801 | +static void | |
802 | +handle_unload_dll () | |
805 | 803 | { |
806 | 804 | LPVOID lpBaseOfDll = current_event.u.UnloadDll.lpBaseOfDll; |
807 | 805 | struct so_list *so; |
@@ -820,7 +818,7 @@ handle_unload_dll (void *dummy) | ||
820 | 818 | DEBUG_EVENTS (("gdb: Unloading dll \"%s\".\n", sodel->so_name)); |
821 | 819 | |
822 | 820 | windows_free_so (sodel); |
823 | - return 1; | |
821 | + return; | |
824 | 822 | } |
825 | 823 | } |
826 | 824 |
@@ -833,8 +831,23 @@ handle_unload_dll (void *dummy) | ||
833 | 831 | 32bit and 64bit worlds). */ |
834 | 832 | complaint (&symfile_complaints, _("dll starting at %s not found."), |
835 | 833 | host_address_to_string (lpBaseOfDll)); |
834 | +} | |
836 | 835 | |
837 | - return 0; | |
836 | +/* Call FUNC wrapped in a TRY/CATCH that swallows all GDB | |
837 | + exceptions. */ | |
838 | + | |
839 | +static void | |
840 | +catch_errors (void (*func) ()) | |
841 | +{ | |
842 | + TRY | |
843 | + { | |
844 | + func (); | |
845 | + } | |
846 | + CATCH (ex, RETURN_MASK_ALL) | |
847 | + { | |
848 | + exception_print (gdb_stderr, ex); | |
849 | + } | |
850 | + END_CATCH | |
838 | 851 | } |
839 | 852 | |
840 | 853 | /* Clear list of loaded DLLs. */ |
@@ -1542,7 +1555,7 @@ get_windows_debug_event (struct target_ops *ops, | ||
1542 | 1555 | CloseHandle (current_event.u.LoadDll.hFile); |
1543 | 1556 | if (saw_create != 1 || ! windows_initialization_done) |
1544 | 1557 | break; |
1545 | - catch_errors (handle_load_dll, NULL, (char *) "", RETURN_MASK_ALL); | |
1558 | + catch_errors (handle_load_dll); | |
1546 | 1559 | ourstatus->kind = TARGET_WAITKIND_LOADED; |
1547 | 1560 | ourstatus->value.integer = 0; |
1548 | 1561 | thread_id = main_thread_id; |
@@ -1555,7 +1568,7 @@ get_windows_debug_event (struct target_ops *ops, | ||
1555 | 1568 | "UNLOAD_DLL_DEBUG_EVENT")); |
1556 | 1569 | if (saw_create != 1 || ! windows_initialization_done) |
1557 | 1570 | break; |
1558 | - catch_errors (handle_unload_dll, NULL, (char *) "", RETURN_MASK_ALL); | |
1571 | + catch_errors (handle_unload_dll); | |
1559 | 1572 | ourstatus->kind = TARGET_WAITKIND_LOADED; |
1560 | 1573 | ourstatus->value.integer = 0; |
1561 | 1574 | thread_id = main_thread_id; |