diff options
author | Yao Qi <yao.qi@linaro.org> | 2017-01-26 14:29:19 +0000 |
---|---|---|
committer | Yao Qi <yao.qi@linaro.org> | 2017-01-26 14:29:19 +0000 |
commit | 80d758749a7a679288e6e72b2e849b814413b719 (patch) | |
tree | 016ba1a6b78e1496d0983dad8ae9a8b9042edfee /gdb/disasm.c | |
parent | 8e87a59348adb7e4c31c8f4faf86df8b17ffb54a (diff) | |
download | gdb-80d758749a7a679288e6e72b2e849b814413b719.zip gdb-80d758749a7a679288e6e72b2e849b814413b719.tar.gz gdb-80d758749a7a679288e6e72b2e849b814413b719.tar.bz2 |
New function null_stream
This patch adds a new function null_stream, which returns a null
stream. The null stream can be used in multiple places. It is
used in gdb_insn_length, and the following patches will use it too.
gdb:
2017-01-26 Yao Qi <yao.qi@linaro.org>
* disasm.c (do_ui_file_delete): Delete.
(gdb_insn_length): Move code creating stream to ...
* utils.c (null_stream): ... here. New function.
* utils.h (null_stream): Declare.
Diffstat (limited to 'gdb/disasm.c')
-rw-r--r-- | gdb/disasm.c | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/gdb/disasm.c b/gdb/disasm.c index f419501..ae3a2f1 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -838,28 +838,13 @@ gdb_print_insn (struct gdbarch *gdbarch, CORE_ADDR memaddr, return length; } -static void -do_ui_file_delete (void *arg) -{ - ui_file_delete ((struct ui_file *) arg); -} - /* Return the length in bytes of the instruction at address MEMADDR in debugged memory. */ int gdb_insn_length (struct gdbarch *gdbarch, CORE_ADDR addr) { - static struct ui_file *null_stream = NULL; - - /* Dummy file descriptor for the disassembler. */ - if (!null_stream) - { - null_stream = ui_file_new (); - make_final_cleanup (do_ui_file_delete, null_stream); - } - - return gdb_print_insn (gdbarch, addr, null_stream, NULL); + return gdb_print_insn (gdbarch, addr, null_stream (), NULL); } /* fprintf-function for gdb_buffered_insn_length. This function is a |