• 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

Revision800eb1cebe736f6867d13e5df40a2c463a4b23ad (tree)
Time2015-02-11 22:40:14
AuthorJan Kratochvil <jan.kratochvil@redh...>
CommiterJan Kratochvil

Log Message

framefilter quit: Code cleanup: Avoid gotos

goto error patters are sometimes AFAIK used in C for the cases like:
int retval=-1;
if (!(a=malloc())) goto error;
if (!(b=malloc())) goto error_a;
if (!(c=malloc())) goto error_b;
retval=0;
error_c: free(c);
error_b: free(b);
error_a: free(a);
error: return retval;

But here there is single error label with one do_cleanups() which I do not find
it worth the goto complication. Without goto one can then furher merge code in
the exit paths in the next patches and ... after all it is all the same, just
without a goto.

gdb/ChangeLog
2015-02-11 Jan Kratochvil <jan.kratochvil@redhat.com>

* python/py-framefilter.c (py_print_frame): Substitute goto error.
Remove the error label.

Change Summary

Incremental Difference

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
11 2015-02-11 Jan Kratochvil <jan.kratochvil@redhat.com>
22
3+ * python/py-framefilter.c (py_print_frame): Substitute goto error.
4+ Remove the error label.
5+
6+2015-02-11 Jan Kratochvil <jan.kratochvil@redhat.com>
7+
38 * python/py-framefilter.c (py_print_frame): Put conditional code paths
49 with goto first, indent the former else codepath left. Put variable
510 'elided' to a new inner block.
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -1033,14 +1033,20 @@ py_print_frame (PyObject *filter, int flags,
10331033 read them if they returned filter object requires us to do so. */
10341034 py_inf_frame = PyObject_CallMethod (filter, "inferior_frame", NULL);
10351035 if (py_inf_frame == NULL)
1036- goto error;
1036+ {
1037+ do_cleanups (cleanup_stack);
1038+ return EXT_LANG_BT_ERROR;
1039+ }
10371040
10381041 frame = frame_object_to_frame_info (py_inf_frame);;
10391042
10401043 Py_DECREF (py_inf_frame);
10411044
10421045 if (frame == NULL)
1043- goto error;
1046+ {
1047+ do_cleanups (cleanup_stack);
1048+ return EXT_LANG_BT_ERROR;
1049+ }
10441050
10451051 TRY_CATCH (except, RETURN_MASK_ALL)
10461052 {
@@ -1049,7 +1055,8 @@ py_print_frame (PyObject *filter, int flags,
10491055 if (except.reason < 0)
10501056 {
10511057 gdbpy_convert_exception (except);
1052- goto error;
1058+ do_cleanups (cleanup_stack);
1059+ return EXT_LANG_BT_ERROR;
10531060 }
10541061
10551062 /* stack-list-variables. */
@@ -1057,7 +1064,10 @@ py_print_frame (PyObject *filter, int flags,
10571064 {
10581065 if (py_mi_print_variables (filter, out, &opts,
10591066 args_type, frame) == EXT_LANG_BT_ERROR)
1060- goto error;
1067+ {
1068+ do_cleanups (cleanup_stack);
1069+ return EXT_LANG_BT_ERROR;
1070+ }
10611071 do_cleanups (cleanup_stack);
10621072 return EXT_LANG_BT_COMPLETED;
10631073 }
@@ -1080,7 +1090,8 @@ py_print_frame (PyObject *filter, int flags,
10801090 if (except.reason < 0)
10811091 {
10821092 gdbpy_convert_exception (except);
1083- goto error;
1093+ do_cleanups (cleanup_stack);
1094+ return EXT_LANG_BT_ERROR;
10841095 }
10851096 }
10861097
@@ -1091,7 +1102,10 @@ py_print_frame (PyObject *filter, int flags,
10911102 PyObject *paddr = PyObject_CallMethod (filter, "address", NULL);
10921103
10931104 if (paddr == NULL)
1094- goto error;
1105+ {
1106+ do_cleanups (cleanup_stack);
1107+ return EXT_LANG_BT_ERROR;
1108+ }
10951109
10961110 if (paddr != Py_None)
10971111 {
@@ -1135,7 +1149,8 @@ py_print_frame (PyObject *filter, int flags,
11351149 if (except.reason < 0)
11361150 {
11371151 gdbpy_convert_exception (except);
1138- goto error;
1152+ do_cleanups (cleanup_stack);
1153+ return EXT_LANG_BT_ERROR;
11391154 }
11401155 }
11411156
@@ -1155,7 +1170,8 @@ py_print_frame (PyObject *filter, int flags,
11551170 if (except.reason < 0)
11561171 {
11571172 gdbpy_convert_exception (except);
1158- goto error;
1173+ do_cleanups (cleanup_stack);
1174+ return EXT_LANG_BT_ERROR;
11591175 }
11601176 }
11611177
@@ -1166,7 +1182,10 @@ py_print_frame (PyObject *filter, int flags,
11661182 const char *function = NULL;
11671183
11681184 if (py_func == NULL)
1169- goto error;
1185+ {
1186+ do_cleanups (cleanup_stack);
1187+ return EXT_LANG_BT_ERROR;
1188+ }
11701189
11711190 if (gdbpy_is_string (py_func))
11721191 {
@@ -1178,7 +1197,8 @@ py_print_frame (PyObject *filter, int flags,
11781197 if (function == NULL)
11791198 {
11801199 Py_DECREF (py_func);
1181- goto error;
1200+ do_cleanups (cleanup_stack);
1201+ return EXT_LANG_BT_ERROR;
11821202 }
11831203 make_cleanup (xfree, function_to_free);
11841204 }
@@ -1188,7 +1208,10 @@ py_print_frame (PyObject *filter, int flags,
11881208 struct bound_minimal_symbol msymbol;
11891209
11901210 if (PyErr_Occurred ())
1191- goto error;
1211+ {
1212+ do_cleanups (cleanup_stack);
1213+ return EXT_LANG_BT_ERROR;
1214+ }
11921215
11931216 msymbol = lookup_minimal_symbol_by_pc (addr);
11941217 if (msymbol.minsym != NULL)
@@ -1200,7 +1223,8 @@ py_print_frame (PyObject *filter, int flags,
12001223 _("FrameDecorator.function: expecting a " \
12011224 "String, integer or None."));
12021225 Py_DECREF (py_func);
1203- goto error;
1226+ do_cleanups (cleanup_stack);
1227+ return EXT_LANG_BT_ERROR;
12041228 }
12051229
12061230 TRY_CATCH (except, RETURN_MASK_ALL)
@@ -1215,7 +1239,8 @@ py_print_frame (PyObject *filter, int flags,
12151239 {
12161240 Py_DECREF (py_func);
12171241 gdbpy_convert_exception (except);
1218- goto error;
1242+ do_cleanups (cleanup_stack);
1243+ return EXT_LANG_BT_ERROR;
12191244 }
12201245 Py_DECREF (py_func);
12211246 }
@@ -1227,7 +1252,10 @@ py_print_frame (PyObject *filter, int flags,
12271252 if (print_args)
12281253 {
12291254 if (py_print_args (filter, out, args_type, frame) == EXT_LANG_BT_ERROR)
1230- goto error;
1255+ {
1256+ do_cleanups (cleanup_stack);
1257+ return EXT_LANG_BT_ERROR;
1258+ }
12311259 }
12321260
12331261 /* File name/source/line number information. */
@@ -1240,7 +1268,8 @@ py_print_frame (PyObject *filter, int flags,
12401268 if (except.reason < 0)
12411269 {
12421270 gdbpy_convert_exception (except);
1243- goto error;
1271+ do_cleanups (cleanup_stack);
1272+ return EXT_LANG_BT_ERROR;
12441273 }
12451274
12461275 if (PyObject_HasAttrString (filter, "filename"))
@@ -1248,7 +1277,10 @@ py_print_frame (PyObject *filter, int flags,
12481277 PyObject *py_fn = PyObject_CallMethod (filter, "filename", NULL);
12491278
12501279 if (py_fn == NULL)
1251- goto error;
1280+ {
1281+ do_cleanups (cleanup_stack);
1282+ return EXT_LANG_BT_ERROR;
1283+ }
12521284
12531285 if (py_fn != Py_None)
12541286 {
@@ -1257,7 +1289,8 @@ py_print_frame (PyObject *filter, int flags,
12571289 if (filename == NULL)
12581290 {
12591291 Py_DECREF (py_fn);
1260- goto error;
1292+ do_cleanups (cleanup_stack);
1293+ return EXT_LANG_BT_ERROR;
12611294 }
12621295
12631296 make_cleanup (xfree, filename);
@@ -1273,7 +1306,8 @@ py_print_frame (PyObject *filter, int flags,
12731306 {
12741307 Py_DECREF (py_fn);
12751308 gdbpy_convert_exception (except);
1276- goto error;
1309+ do_cleanups (cleanup_stack);
1310+ return EXT_LANG_BT_ERROR;
12771311 }
12781312 }
12791313 Py_DECREF (py_fn);
@@ -1285,7 +1319,10 @@ py_print_frame (PyObject *filter, int flags,
12851319 int line;
12861320
12871321 if (py_line == NULL)
1288- goto error;
1322+ {
1323+ do_cleanups (cleanup_stack);
1324+ return EXT_LANG_BT_ERROR;
1325+ }
12891326
12901327 if (py_line != Py_None)
12911328 {
@@ -1300,7 +1337,8 @@ py_print_frame (PyObject *filter, int flags,
13001337 {
13011338 Py_DECREF (py_line);
13021339 gdbpy_convert_exception (except);
1303- goto error;
1340+ do_cleanups (cleanup_stack);
1341+ return EXT_LANG_BT_ERROR;
13041342 }
13051343 }
13061344 Py_DECREF (py_line);
@@ -1319,7 +1357,8 @@ py_print_frame (PyObject *filter, int flags,
13191357 if (except.reason < 0)
13201358 {
13211359 gdbpy_convert_exception (except);
1322- goto error;
1360+ do_cleanups (cleanup_stack);
1361+ return EXT_LANG_BT_ERROR;
13231362 }
13241363 }
13251364
@@ -1327,7 +1366,10 @@ py_print_frame (PyObject *filter, int flags,
13271366 {
13281367 if (py_print_locals (filter, out, args_type, indent,
13291368 frame) == EXT_LANG_BT_ERROR)
1330- goto error;
1369+ {
1370+ do_cleanups (cleanup_stack);
1371+ return EXT_LANG_BT_ERROR;
1372+ }
13311373 }
13321374
13331375 {
@@ -1336,7 +1378,10 @@ py_print_frame (PyObject *filter, int flags,
13361378 /* Finally recursively print elided frames, if any. */
13371379 elided = get_py_iter_from_func (filter, "elided");
13381380 if (elided == NULL)
1339- goto error;
1381+ {
1382+ do_cleanups (cleanup_stack);
1383+ return EXT_LANG_BT_ERROR;
1384+ }
13401385
13411386 make_cleanup_py_decref (elided);
13421387 if (elided != Py_None)
@@ -1358,23 +1403,23 @@ py_print_frame (PyObject *filter, int flags,
13581403 if (success == EXT_LANG_BT_ERROR)
13591404 {
13601405 Py_DECREF (item);
1361- goto error;
1406+ do_cleanups (cleanup_stack);
1407+ return EXT_LANG_BT_ERROR;
13621408 }
13631409
13641410 Py_DECREF (item);
13651411 }
13661412 if (item == NULL && PyErr_Occurred ())
1367- goto error;
1413+ {
1414+ do_cleanups (cleanup_stack);
1415+ return EXT_LANG_BT_ERROR;
1416+ }
13681417 }
13691418 }
13701419
13711420
13721421 do_cleanups (cleanup_stack);
13731422 return EXT_LANG_BT_COMPLETED;
1374-
1375- error:
1376- do_cleanups (cleanup_stack);
1377- return EXT_LANG_BT_ERROR;
13781423 }
13791424
13801425 /* Helper function to initiate frame filter invocation at starting