Если вы определяете функцию в вашей программе:
void flush_all(void) {
fflush(NULL);
}
, вы можете вызвать эту функцию из gdb(1)
с помощью:
call flush_all()
Короткая демонстрация:
$ cat cat.c
#include <stdio.h>
int main(int argc, char* argv[]) {
printf("this is a partial write");
printf("this is a partial write");
printf("this is a partial write");
printf("this is a partial write");
printf("this is a partial write");
return 0;
}
void flush_all(void) {
fflush(NULL);
}
$ gcc -g -o cat cat.c
$ gdb
GNU gdb (Ubuntu/Linaro 7.2-1ubuntu11) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file cat
Reading symbols from /home/sarnold/tmp/cat...done.
(gdb) break printf
Breakpoint 1 at 0x400428
(gdb) run
Starting program: /home/sarnold/tmp/cat
Breakpoint 1, __printf (format=0x4006bc "this is a partial write") at printf.c:30
30 printf.c: No such file or directory.
in printf.c
(gdb) cont
Continuing.
Breakpoint 1, __printf (format=0x4006bc "this is a partial write") at printf.c:30
30 in printf.c
(gdb) cont
Continuing.
Breakpoint 1, __printf (format=0x4006bc "this is a partial write") at printf.c:30
30 in printf.c
(gdb) call flush_all()
this is a partial writethis is a partial write(gdb) ^CQuit
(gdb) quit