Commit cbfde6ee by Vladislav Ivanishin Committed by Vladislav Ivanishin

gdbhooks.py: dump-fn, dot-fn: cast ret values of fopen/fclose

Work around the following

    (gdb) Python Exception <class 'gdb.error'> 'fclose@@GLIBC_2.2.5' has
    unknown return type; cast the call to its declared return type:
    (gdb) Error occurred in Python: 'fclose@@GLIBC_2.2.5' has unknown
    return type; cast the call to its declared return type

This is due to GDB not being able to pick up and use the return types from
debug info for external declarations.

2019-07-14  Vladislav Ivanishin <vlad@ispras.ru>

        * gdbhooks.py (DumpFn.invoke): Add explicit casts of return values of
        fopen and fclose to their respective types.
        (DotFn.invoke): Ditto.

From-SVN: r273480
parent a20f263b
2019-07-14 Vladislav Ivanishin <vlad@ispras.ru>
* gdbhooks.py (DumpFn.invoke): Add explicit casts of return values of
fopen and fclose to their respective types.
(DotFn.invoke): Ditto.
2019-07-14 Jan Hubicka <hubicka@ucw.cz> 2019-07-14 Jan Hubicka <hubicka@ucw.cz>
* ipa-fnsummary.c (ipa_dump_hints): Do not dump array_index. * ipa-fnsummary.c (ipa_dump_hints): Do not dump array_index.
......
...@@ -740,18 +740,17 @@ class DumpFn(gdb.Command): ...@@ -740,18 +740,17 @@ class DumpFn(gdb.Command):
f.close() f.close()
# Open file # Open file
fp = gdb.parse_and_eval("fopen (\"%s\", \"w\")" % filename) fp = gdb.parse_and_eval("(FILE *) fopen (\"%s\", \"w\")" % filename)
if fp == 0: if fp == 0:
print ("Could not open file: %s" % filename) print ("Could not open file: %s" % filename)
return return
fp = "(FILE *)%u" % fp
# Dump function to file # Dump function to file
_ = gdb.parse_and_eval("dump_function_to_file (%s, %s, %u)" % _ = gdb.parse_and_eval("dump_function_to_file (%s, %s, %u)" %
(func, fp, flags)) (func, fp, flags))
# Close file # Close file
ret = gdb.parse_and_eval("fclose (%s)" % fp) ret = gdb.parse_and_eval("(int) fclose (%s)" % fp)
if ret != 0: if ret != 0:
print ("Could not close file: %s" % filename) print ("Could not close file: %s" % filename)
return return
...@@ -810,11 +809,10 @@ class DotFn(gdb.Command): ...@@ -810,11 +809,10 @@ class DotFn(gdb.Command):
# Close and reopen temp file to get C FILE* # Close and reopen temp file to get C FILE*
f.close() f.close()
fp = gdb.parse_and_eval("fopen (\"%s\", \"w\")" % filename) fp = gdb.parse_and_eval("(FILE *) fopen (\"%s\", \"w\")" % filename)
if fp == 0: if fp == 0:
print("Cannot open temp file") print("Cannot open temp file")
return return
fp = "(FILE *)%u" % fp
# Write graph to temp file # Write graph to temp file
_ = gdb.parse_and_eval("start_graph_dump (%s, \"<debug>\")" % fp) _ = gdb.parse_and_eval("start_graph_dump (%s, \"<debug>\")" % fp)
...@@ -823,7 +821,7 @@ class DotFn(gdb.Command): ...@@ -823,7 +821,7 @@ class DotFn(gdb.Command):
_ = gdb.parse_and_eval("end_graph_dump (%s)" % fp) _ = gdb.parse_and_eval("end_graph_dump (%s)" % fp)
# Close temp file # Close temp file
ret = gdb.parse_and_eval("fclose (%s)" % fp) ret = gdb.parse_and_eval("(int) fclose (%s)" % fp)
if ret != 0: if ret != 0:
print("Could not close temp file: %s" % filename) print("Could not close temp file: %s" % filename)
return return
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment