diff options
author | Tom de Vries <tdevries@suse.de> | 2021-09-09 12:29:39 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2021-09-09 12:29:39 +0200 |
commit | 86fe51fcc7a78def0b3ed289c0e1e7e8af283acc (patch) | |
tree | 253f4db9ce3f893e710d1163aabb08179dee46bc /gdb/gdbcmd.h | |
parent | 0b233e34c801eac78a5e03b66f18585cf368e4d5 (diff) | |
download | fsf-binutils-gdb-86fe51fcc7a78def0b3ed289c0e1e7e8af283acc.zip fsf-binutils-gdb-86fe51fcc7a78def0b3ed289c0e1e7e8af283acc.tar.gz fsf-binutils-gdb-86fe51fcc7a78def0b3ed289c0e1e7e8af283acc.tar.bz2 |
[gdb/testsuite] Reimplement gdb.gdb/complaints.exp as unittest
When building gdb with "-Wall -O2 -g -flto=auto", I run into:
...
(gdb) call clear_complaints()^M
No symbol "clear_complaints" in current context.^M
(gdb) FAIL: gdb.gdb/complaints.exp: clear complaints
...
The problem is that lto has optimized away the clear_complaints function
and consequently the selftest doesn't work.
Fix this by reimplementing the selftest as a unit test.
Factor out two new functions:
- void
execute_fn_to_ui_file (struct ui_file *file, std::function<void(void)> fn);
- std::string
execute_fn_to_string (std::function<void(void)> fn, bool term_out);
and use the latter to capture the complaints output.
Tested on x86_64-linux.
Diffstat (limited to 'gdb/gdbcmd.h')
-rw-r--r-- | gdb/gdbcmd.h | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/gdb/gdbcmd.h b/gdb/gdbcmd.h index f541ebd..27550c1 100644 --- a/gdb/gdbcmd.h +++ b/gdb/gdbcmd.h @@ -134,17 +134,29 @@ extern struct cmd_list_element *save_cmdlist; extern void execute_command (const char *, int); -/* Run execute_command for P and FROM_TTY. Capture its output into the - returned string, do not display it to the screen. The global BATCH_FLAG - will temporarily be set to true. When TERM_OUT is true the output is - collected with terminal behaviour (e.g. with styling). When TERM_OUT is - false raw output will be collected (e.g. no styling). */ +/* Run FN. Sends its output to FILE, do not display it to the screen. + The global BATCH_FLAG will be temporarily set to true. */ + +extern void execute_fn_to_ui_file (struct ui_file *file, std::function<void(void)> fn); + +/* Run FN. Capture its output into the returned string, do not display it + to the screen. The global BATCH_FLAG will temporarily be set to true. + When TERM_OUT is true the output is collected with terminal behaviour + (e.g. with styling). When TERM_OUT is false raw output will be collected + (e.g. no styling). */ + +extern std::string execute_fn_to_string (std::function<void(void)> fn, bool term_out); + +/* As execute_fn_to_ui_file, but run execute_command for P and FROM_TTY. */ -extern std::string execute_command_to_string (const char *p, int from_tty, - bool term_out); extern void execute_command_to_ui_file (struct ui_file *file, const char *p, int from_tty); +/* As execute_fn_to_string, but run execute_command for P and FROM_TTY. */ + +extern std::string execute_command_to_string (const char *p, int from_tty, + bool term_out); + extern void print_command_line (struct command_line *, unsigned int, struct ui_file *); extern void print_command_lines (struct ui_out *, |