• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
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

修订版c6dc63a16299e22fcb5bc13b34cb402a1bfcf6b9 (tree)
时间2017-09-12 07:15:11
作者Tom Tromey <tom@trom...>
CommiterTom Tromey

Log Message

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.

更改概述

差异

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
11 2017-09-11 Tom Tromey <tom@tromey.com>
22
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+
314 * findcmd.c (put_bits): Take a gdb::byte_vector.
415 (parse_find_args): Return gdb::byte_vector. "args" now const.
516 Remove "pattern_bufp" and "pattern_lenp" parameters. Remove
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -11979,7 +11979,6 @@ ada_exception_support_info_sniffer (void)
1197911979 static int
1198011980 is_known_support_routine (struct frame_info *frame)
1198111981 {
11982- char *func_name;
1198311982 enum language func_lang;
1198411983 int i;
1198511984 const char *fullname;
@@ -12018,21 +12017,18 @@ is_known_support_routine (struct frame_info *frame)
1201812017
1201912018 /* Check whether the function is a GNAT-generated entity. */
1202012019
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);
1202212022 if (func_name == NULL)
1202312023 return 1;
1202412024
1202512025 for (i = 0; known_auxiliary_function_name_patterns[i] != NULL; i += 1)
1202612026 {
1202712027 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;
1203312030 }
1203412031
12035- xfree (func_name);
1203612032 return 0;
1203712033 }
1203812034
@@ -12076,7 +12072,6 @@ ada_unhandled_exception_name_addr_from_raise (void)
1207612072 int frame_level;
1207712073 struct frame_info *fi;
1207812074 struct ada_inferior_data *data = get_ada_inferior_data (current_inferior ());
12079- struct cleanup *old_chain;
1208012075
1208112076 /* To determine the name of this exception, we need to select
1208212077 the frame corresponding to RAISE_SYM_NAME. This frame is
@@ -12087,24 +12082,20 @@ ada_unhandled_exception_name_addr_from_raise (void)
1208712082 if (fi != NULL)
1208812083 fi = get_prev_frame (fi);
1208912084
12090- old_chain = make_cleanup (null_cleanup, NULL);
1209112085 while (fi != NULL)
1209212086 {
12093- char *func_name;
1209412087 enum language func_lang;
1209512088
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);
1209712091 if (func_name != NULL)
1209812092 {
12099- make_cleanup (xfree, func_name);
12100-
12101- if (strcmp (func_name,
12093+ if (strcmp (func_name.get (),
1210212094 data->exception_info->catch_exception_sym) == 0)
1210312095 break; /* We found the frame we were looking for... */
1210412096 fi = get_prev_frame (fi);
1210512097 }
1210612098 }
12107- do_cleanups (old_chain);
1210812099
1210912100 if (fi == NULL)
1211012101 return 0;
--- a/gdb/guile/scm-frame.c
+++ b/gdb/guile/scm-frame.c
@@ -418,7 +418,7 @@ static SCM
418418 gdbscm_frame_name (SCM self)
419419 {
420420 frame_smob *f_smob;
421- char *name = NULL;
421+ gdb::unique_xmalloc_ptr<char> name;
422422 enum language lang = language_minimal;
423423 struct frame_info *frame = NULL;
424424 SCM result;
@@ -429,11 +429,10 @@ gdbscm_frame_name (SCM self)
429429 {
430430 frame = frscm_frame_smob_to_frame (f_smob);
431431 if (frame != NULL)
432- find_frame_funname (frame, &name, &lang, NULL);
432+ name = find_frame_funname (frame, &lang, NULL);
433433 }
434434 CATCH (except, RETURN_MASK_ALL)
435435 {
436- xfree (name);
437436 GDBSCM_HANDLE_GDB_EXCEPTION (except);
438437 }
439438 END_CATCH
@@ -445,10 +444,7 @@ gdbscm_frame_name (SCM self)
445444 }
446445
447446 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 ());
452448 else
453449 result = SCM_BOOL_F;
454450
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -119,7 +119,7 @@ static PyObject *
119119 frapy_name (PyObject *self, PyObject *args)
120120 {
121121 struct frame_info *frame;
122- char *name = NULL;
122+ gdb::unique_xmalloc_ptr<char> name;
123123 enum language lang;
124124 PyObject *result;
125125
@@ -127,19 +127,18 @@ frapy_name (PyObject *self, PyObject *args)
127127 {
128128 FRAPY_REQUIRE_VALID (self, frame);
129129
130- find_frame_funname (frame, &name, &lang, NULL);
130+ name = find_frame_funname (frame, &lang, NULL);
131131 }
132132 CATCH (except, RETURN_MASK_ALL)
133133 {
134- xfree (name);
135134 GDB_PY_HANDLE_EXCEPTION (except);
136135 }
137136 END_CATCH
138137
139138 if (name)
140139 {
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);
143142 }
144143 else
145144 {
@@ -334,13 +333,12 @@ frapy_function (PyObject *self, PyObject *args)
334333
335334 TRY
336335 {
337- char *funname;
338336 enum language funlang;
339337
340338 FRAPY_REQUIRE_VALID (self, frame);
341339
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);
344342 }
345343 CATCH (except, RETURN_MASK_ALL)
346344 {
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -1032,16 +1032,16 @@ get_last_displayed_sal ()
10321032 }
10331033
10341034
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. */
10371037
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)
10411041 {
10421042 struct symbol *func;
1043+ gdb::unique_xmalloc_ptr<char> funname;
10431044
1044- *funname = NULL;
10451045 *funlang = language_unknown;
10461046 if (funcp)
10471047 *funcp = NULL;
@@ -1084,7 +1084,7 @@ find_frame_funname (struct frame_info *frame, char **funname,
10841084 /* We also don't know anything about the function besides
10851085 its address and name. */
10861086 func = 0;
1087- *funname = xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym));
1087+ funname.reset (xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym)));
10881088 *funlang = MSYMBOL_LANGUAGE (msymbol.minsym);
10891089 }
10901090 else
@@ -1104,14 +1104,13 @@ find_frame_funname (struct frame_info *frame, char **funname,
11041104 char *func_only = cp_remove_params (print_name);
11051105
11061106 if (func_only)
1107- *funname = func_only;
1107+ funname.reset (func_only);
11081108 }
11091109
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));
11151114 }
11161115 }
11171116 else
@@ -1120,15 +1119,17 @@ find_frame_funname (struct frame_info *frame, char **funname,
11201119 CORE_ADDR pc;
11211120
11221121 if (!get_frame_address_in_block_if_available (frame, &pc))
1123- return;
1122+ return funname;
11241123
11251124 msymbol = lookup_minimal_symbol_by_pc (pc);
11261125 if (msymbol.minsym != NULL)
11271126 {
1128- *funname = xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym));
1127+ funname.reset (xstrdup (MSYMBOL_PRINT_NAME (msymbol.minsym)));
11291128 *funlang = MSYMBOL_LANGUAGE (msymbol.minsym);
11301129 }
11311130 }
1131+
1132+ return funname;
11321133 }
11331134
11341135 static void
@@ -1138,9 +1139,7 @@ print_frame (struct frame_info *frame, int print_level,
11381139 {
11391140 struct gdbarch *gdbarch = get_frame_arch (frame);
11401141 struct ui_out *uiout = current_uiout;
1141- char *funname = NULL;
11421142 enum language funlang = language_unknown;
1143- struct cleanup *old_chain;
11441143 struct value_print_options opts;
11451144 struct symbol *func;
11461145 CORE_ADDR pc = 0;
@@ -1148,9 +1147,8 @@ print_frame (struct frame_info *frame, int print_level,
11481147
11491148 pc_p = get_frame_pc_if_available (frame, &pc);
11501149
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);
11541152
11551153 annotate_frame_begin (print_level ? frame_relative_level (frame) : 0,
11561154 gdbarch, pc);
@@ -1181,7 +1179,7 @@ print_frame (struct frame_info *frame, int print_level,
11811179 annotate_frame_function_name ();
11821180
11831181 string_file stb;
1184- fprintf_symbol_filtered (&stb, funname ? funname : "??",
1182+ fprintf_symbol_filtered (&stb, funname ? funname.get () : "??",
11851183 funlang, DMGL_ANSI);
11861184 uiout->field_stream ("func", stb);
11871185 uiout->wrap_hint (" ");
@@ -1257,7 +1255,6 @@ print_frame (struct frame_info *frame, int print_level,
12571255 }
12581256
12591257 uiout->text ("\n");
1260- do_cleanups (old_chain);
12611258 }
12621259
12631260
--- a/gdb/stack.h
+++ b/gdb/stack.h
@@ -22,8 +22,9 @@
2222
2323 void select_frame_command (char *level_exp, int from_tty);
2424
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);
2728
2829 typedef void (*iterate_over_block_arg_local_vars_cb) (const char *print_name,
2930 struct symbol *sym,