GNU Binutils with patches for OS216
修订版 | c6dc63a16299e22fcb5bc13b34cb402a1bfcf6b9 (tree) |
---|---|
时间 | 2017-09-12 07:15:11 |
作者 | Tom Tromey <tom@trom...> |
Commiter | Tom Tromey |
Remove cleanups from find_frame_funname
This changes find_frame_funname to return a unique_xmalloc_ptr and
then fixes up the callers. This removes several cleanups.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* ada-lang.c (is_known_support_routine): Update.
(ada_unhandled_exception_name_addr_from_raise): Update.
* guile/scm-frame.c (gdbscm_frame_name): Update.
* python/py-frame.c (frapy_name): Update.
(frapy_function): Update.
* stack.h (find_frame_funname): Update.
* stack.c (find_frame_funname): Return unique_xmalloc_ptr.
(print_frame): Update.
@@ -1,5 +1,16 @@ | ||
1 | 1 | 2017-09-11 Tom Tromey <tom@tromey.com> |
2 | 2 | |
3 | + * ada-lang.c (is_known_support_routine): Update. | |
4 | + (ada_unhandled_exception_name_addr_from_raise): Update. | |
5 | + * guile/scm-frame.c (gdbscm_frame_name): Update. | |
6 | + * python/py-frame.c (frapy_name): Update. | |
7 | + (frapy_function): Update. | |
8 | + * stack.h (find_frame_funname): Update. | |
9 | + * stack.c (find_frame_funname): Return unique_xmalloc_ptr. | |
10 | + (print_frame): Update. | |
11 | + | |
12 | +2017-09-11 Tom Tromey <tom@tromey.com> | |
13 | + | |
3 | 14 | * findcmd.c (put_bits): Take a gdb::byte_vector. |
4 | 15 | (parse_find_args): Return gdb::byte_vector. "args" now const. |
5 | 16 | Remove "pattern_bufp" and "pattern_lenp" parameters. Remove |
@@ -11979,7 +11979,6 @@ ada_exception_support_info_sniffer (void) | ||
11979 | 11979 | static int |
11980 | 11980 | is_known_support_routine (struct frame_info *frame) |
11981 | 11981 | { |
11982 | - char *func_name; | |
11983 | 11982 | enum language func_lang; |
11984 | 11983 | int i; |
11985 | 11984 | const char *fullname; |
@@ -12018,21 +12017,18 @@ is_known_support_routine (struct frame_info *frame) | ||
12018 | 12017 | |
12019 | 12018 | /* Check whether the function is a GNAT-generated entity. */ |
12020 | 12019 | |
12021 | - find_frame_funname (frame, &func_name, &func_lang, NULL); | |
12020 | + gdb::unique_xmalloc_ptr<char> func_name | |
12021 | + = find_frame_funname (frame, &func_lang, NULL); | |
12022 | 12022 | if (func_name == NULL) |
12023 | 12023 | return 1; |
12024 | 12024 | |
12025 | 12025 | for (i = 0; known_auxiliary_function_name_patterns[i] != NULL; i += 1) |
12026 | 12026 | { |
12027 | 12027 | re_comp (known_auxiliary_function_name_patterns[i]); |
12028 | - if (re_exec (func_name)) | |
12029 | - { | |
12030 | - xfree (func_name); | |
12031 | - return 1; | |
12032 | - } | |
12028 | + if (re_exec (func_name.get ())) | |
12029 | + return 1; | |
12033 | 12030 | } |
12034 | 12031 | |
12035 | - xfree (func_name); | |
12036 | 12032 | return 0; |
12037 | 12033 | } |
12038 | 12034 |
@@ -12076,7 +12072,6 @@ ada_unhandled_exception_name_addr_from_raise (void) | ||
12076 | 12072 | int frame_level; |
12077 | 12073 | struct frame_info *fi; |
12078 | 12074 | struct ada_inferior_data *data = get_ada_inferior_data (current_inferior ()); |
12079 | - struct cleanup *old_chain; | |
12080 | 12075 | |
12081 | 12076 | /* To determine the name of this exception, we need to select |
12082 | 12077 | the frame corresponding to RAISE_SYM_NAME. This frame is |
@@ -12087,24 +12082,20 @@ ada_unhandled_exception_name_addr_from_raise (void) | ||
12087 | 12082 | if (fi != NULL) |
12088 | 12083 | fi = get_prev_frame (fi); |
12089 | 12084 | |
12090 | - old_chain = make_cleanup (null_cleanup, NULL); | |
12091 | 12085 | while (fi != NULL) |
12092 | 12086 | { |
12093 | - char *func_name; | |
12094 | 12087 | enum language func_lang; |
12095 | 12088 | |
12096 | - find_frame_funname (fi, &func_name, &func_lang, NULL); | |
12089 | + gdb::unique_xmalloc_ptr<char> func_name | |
12090 | + = find_frame_funname (fi, &func_lang, NULL); | |
12097 | 12091 | if (func_name != NULL) |
12098 | 12092 | { |
12099 | - make_cleanup (xfree, func_name); | |
12100 | - | |
12101 | - if (strcmp (func_name, | |
12093 | + if (strcmp (func_name.get (), | |
12102 | 12094 | data->exception_info->catch_exception_sym) == 0) |
12103 | 12095 | break; /* We found the frame we were looking for... */ |
12104 | 12096 | fi = get_prev_frame (fi); |
12105 | 12097 | } |
12106 | 12098 | } |
12107 | - do_cleanups (old_chain); | |
12108 | 12099 | |
12109 | 12100 | if (fi == NULL) |
12110 | 12101 | return 0; |
@@ -418,7 +418,7 @@ static SCM | ||
418 | 418 | gdbscm_frame_name (SCM self) |
419 | 419 | { |
420 | 420 | frame_smob *f_smob; |
421 | - char *name = NULL; | |
421 | + gdb::unique_xmalloc_ptr<char> name; | |
422 | 422 | enum language lang = language_minimal; |
423 | 423 | struct frame_info *frame = NULL; |
424 | 424 | SCM result; |
@@ -429,11 +429,10 @@ gdbscm_frame_name (SCM self) | ||
429 | 429 | { |
430 | 430 | frame = frscm_frame_smob_to_frame (f_smob); |
431 | 431 | if (frame != NULL) |
432 | - find_frame_funname (frame, &name, &lang, NULL); | |
432 | + name = find_frame_funname (frame, &lang, NULL); | |
433 | 433 | } |
434 | 434 | CATCH (except, RETURN_MASK_ALL) |
435 | 435 | { |
436 | - xfree (name); | |
437 | 436 | GDBSCM_HANDLE_GDB_EXCEPTION (except); |
438 | 437 | } |
439 | 438 | END_CATCH |
@@ -445,10 +444,7 @@ gdbscm_frame_name (SCM self) | ||
445 | 444 | } |
446 | 445 | |
447 | 446 | if (name != NULL) |
448 | - { | |
449 | - result = gdbscm_scm_from_c_string (name); | |
450 | - xfree (name); | |
451 | - } | |
447 | + result = gdbscm_scm_from_c_string (name.get ()); | |
452 | 448 | else |
453 | 449 | result = SCM_BOOL_F; |
454 | 450 |
@@ -119,7 +119,7 @@ static PyObject * | ||
119 | 119 | frapy_name (PyObject *self, PyObject *args) |
120 | 120 | { |
121 | 121 | struct frame_info *frame; |
122 | - char *name = NULL; | |
122 | + gdb::unique_xmalloc_ptr<char> name; | |
123 | 123 | enum language lang; |
124 | 124 | PyObject *result; |
125 | 125 |
@@ -127,19 +127,18 @@ frapy_name (PyObject *self, PyObject *args) | ||
127 | 127 | { |
128 | 128 | FRAPY_REQUIRE_VALID (self, frame); |
129 | 129 | |
130 | - find_frame_funname (frame, &name, &lang, NULL); | |
130 | + name = find_frame_funname (frame, &lang, NULL); | |
131 | 131 | } |
132 | 132 | CATCH (except, RETURN_MASK_ALL) |
133 | 133 | { |
134 | - xfree (name); | |
135 | 134 | GDB_PY_HANDLE_EXCEPTION (except); |
136 | 135 | } |
137 | 136 | END_CATCH |
138 | 137 | |
139 | 138 | if (name) |
140 | 139 | { |
141 | - result = PyUnicode_Decode (name, strlen (name), host_charset (), NULL); | |
142 | - xfree (name); | |
140 | + result = PyUnicode_Decode (name.get (), strlen (name.get ()), | |
141 | + host_charset (), NULL); | |
143 | 142 | } |
144 | 143 | else |
145 | 144 | { |
@@ -334,13 +333,12 @@ frapy_function (PyObject *self, PyObject *args) | ||
334 | 333 | |
335 | 334 | TRY |
336 | 335 | { |
337 | - char *funname; | |
338 | 336 | enum language funlang; |
339 | 337 | |
340 | 338 | FRAPY_REQUIRE_VALID (self, frame); |
341 | 339 | |
342 | - find_frame_funname (frame, &funname, &funlang, &sym); | |
343 | - xfree (funname); | |
340 | + gdb::unique_xmalloc_ptr<char> funname | |
341 | + = find_frame_funname (frame, &funlang, &sym); | |
344 | 342 | } |
345 | 343 | CATCH (except, RETURN_MASK_ALL) |
346 | 344 | { |
@@ -1032,16 +1032,16 @@ get_last_displayed_sal () | ||
1032 | 1032 | } |
1033 | 1033 | |
1034 | 1034 | |
1035 | -/* Attempt to obtain the FUNNAME, FUNLANG and optionally FUNCP of the function | |
1036 | - corresponding to FRAME. FUNNAME needs to be freed by the caller. */ | |
1035 | +/* Attempt to obtain the name, FUNLANG and optionally FUNCP of the function | |
1036 | + corresponding to FRAME. */ | |
1037 | 1037 | |
1038 | -void | |
1039 | -find_frame_funname (struct frame_info *frame, char **funname, | |
1040 | - enum language *funlang, struct symbol **funcp) | |
1038 | +gdb::unique_xmalloc_ptr<char> | |
1039 | +find_frame_funname (struct frame_info *frame, enum language *funlang, | |
1040 | + struct symbol **funcp) | |
1041 | 1041 | { |
1042 | 1042 | struct symbol *func; |
1043 | + gdb::unique_xmalloc_ptr<char> funname; | |
1043 | 1044 | |
1044 | - *funname = NULL; | |
1045 | 1045 | *funlang = language_unknown; |
1046 | 1046 | if (funcp) |
1047 | 1047 | *funcp = NULL; |
@@ -1084,7 +1084,7 @@ find_frame_funname (struct frame_info *frame, char **funname, | ||
1084 | 1084 | /* We also don't know anything about the function besides |
1085 | 1085 | its address and name. */ |
1086 | 1086 | func = 0; |
1087 | - *funname = xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym)); | |
1087 | + funname.reset (xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym))); | |
1088 | 1088 | *funlang = MSYMBOL_LANGUAGE (msymbol.minsym); |
1089 | 1089 | } |
1090 | 1090 | else |
@@ -1104,14 +1104,13 @@ find_frame_funname (struct frame_info *frame, char **funname, | ||
1104 | 1104 | char *func_only = cp_remove_params (print_name); |
1105 | 1105 | |
1106 | 1106 | if (func_only) |
1107 | - *funname = func_only; | |
1107 | + funname.reset (func_only); | |
1108 | 1108 | } |
1109 | 1109 | |
1110 | - /* If we didn't hit the C++ case above, set *funname here. | |
1111 | - This approach is taken to avoid having to install a | |
1112 | - cleanup in case cp_remove_params can throw. */ | |
1113 | - if (*funname == NULL) | |
1114 | - *funname = xstrdup (print_name); | |
1110 | + /* If we didn't hit the C++ case above, set *funname | |
1111 | + here. */ | |
1112 | + if (funname == NULL) | |
1113 | + funname.reset (xstrdup (print_name)); | |
1115 | 1114 | } |
1116 | 1115 | } |
1117 | 1116 | else |
@@ -1120,15 +1119,17 @@ find_frame_funname (struct frame_info *frame, char **funname, | ||
1120 | 1119 | CORE_ADDR pc; |
1121 | 1120 | |
1122 | 1121 | if (!get_frame_address_in_block_if_available (frame, &pc)) |
1123 | - return; | |
1122 | + return funname; | |
1124 | 1123 | |
1125 | 1124 | msymbol = lookup_minimal_symbol_by_pc (pc); |
1126 | 1125 | if (msymbol.minsym != NULL) |
1127 | 1126 | { |
1128 | - *funname = xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym)); | |
1127 | + funname.reset (xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym))); | |
1129 | 1128 | *funlang = MSYMBOL_LANGUAGE (msymbol.minsym); |
1130 | 1129 | } |
1131 | 1130 | } |
1131 | + | |
1132 | + return funname; | |
1132 | 1133 | } |
1133 | 1134 | |
1134 | 1135 | static void |
@@ -1138,9 +1139,7 @@ print_frame (struct frame_info *frame, int print_level, | ||
1138 | 1139 | { |
1139 | 1140 | struct gdbarch *gdbarch = get_frame_arch (frame); |
1140 | 1141 | struct ui_out *uiout = current_uiout; |
1141 | - char *funname = NULL; | |
1142 | 1142 | enum language funlang = language_unknown; |
1143 | - struct cleanup *old_chain; | |
1144 | 1143 | struct value_print_options opts; |
1145 | 1144 | struct symbol *func; |
1146 | 1145 | CORE_ADDR pc = 0; |
@@ -1148,9 +1147,8 @@ print_frame (struct frame_info *frame, int print_level, | ||
1148 | 1147 | |
1149 | 1148 | pc_p = get_frame_pc_if_available (frame, &pc); |
1150 | 1149 | |
1151 | - | |
1152 | - find_frame_funname (frame, &funname, &funlang, &func); | |
1153 | - old_chain = make_cleanup (xfree, funname); | |
1150 | + gdb::unique_xmalloc_ptr<char> funname | |
1151 | + = find_frame_funname (frame, &funlang, &func); | |
1154 | 1152 | |
1155 | 1153 | annotate_frame_begin (print_level ? frame_relative_level (frame) : 0, |
1156 | 1154 | gdbarch, pc); |
@@ -1181,7 +1179,7 @@ print_frame (struct frame_info *frame, int print_level, | ||
1181 | 1179 | annotate_frame_function_name (); |
1182 | 1180 | |
1183 | 1181 | string_file stb; |
1184 | - fprintf_symbol_filtered (&stb, funname ? funname : "??", | |
1182 | + fprintf_symbol_filtered (&stb, funname ? funname.get () : "??", | |
1185 | 1183 | funlang, DMGL_ANSI); |
1186 | 1184 | uiout->field_stream ("func", stb); |
1187 | 1185 | uiout->wrap_hint (" "); |
@@ -1257,7 +1255,6 @@ print_frame (struct frame_info *frame, int print_level, | ||
1257 | 1255 | } |
1258 | 1256 | |
1259 | 1257 | uiout->text ("\n"); |
1260 | - do_cleanups (old_chain); | |
1261 | 1258 | } |
1262 | 1259 | |
1263 | 1260 |
@@ -22,8 +22,9 @@ | ||
22 | 22 | |
23 | 23 | void select_frame_command (char *level_exp, int from_tty); |
24 | 24 | |
25 | -void find_frame_funname (struct frame_info *frame, char **funname, | |
26 | - enum language *funlang, struct symbol **funcp); | |
25 | +gdb::unique_xmalloc_ptr<char> find_frame_funname (struct frame_info *frame, | |
26 | + enum language *funlang, | |
27 | + struct symbol **funcp); | |
27 | 28 | |
28 | 29 | typedef void (*iterate_over_block_arg_local_vars_cb) (const char *print_name, |
29 | 30 | struct symbol *sym, |