On Wed, Feb 17, 2016 at 1:41 PM, Tom de Vries <tom_devr...@mentor.com> wrote: > Hi, > > once in a while I'm in a gdb debug session debugging cc1, and want to print > the current function to file. > > There's a debug function debug_function that prints a function to stderr, > and there are methods to redirect output of a command to a file ( > https://sourceware.org/gdb/onlinedocs/gdb/Logging-Output.html ). > > And there's a function dump_function_to_file that takes a FILE* parameter, > which could be combined with open/close calls in gdb. > > But I think a short-hand is easier. > > This patch adds a function debug_function_to_file. It can f.i. be called as: > ... > (gdb) call debug_function_to_file (cfun.decl, "foo.1.txt", 0) > ... > > Hmm, now I wonder if the order 'cfun.decl, 0, "foo.1.txt"' would make more > sense (first two parameters the same as in debug_function). > > OK for stage1 trunk if bootstrap and reg-test succeeds?
Bonus for making this a helper in gdbhooks.py instead, using fopen/fclose and the existing inferior calls. Richard. > Thanks, > - Tom