From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15079 invoked by alias); 22 Jul 2011 16:48:52 -0000 Mailing-List: contact archer-commits-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: Received: (qmail 15037 invoked by uid 9674); 22 Jul 2011 16:48:52 -0000 Date: Fri, 22 Jul 2011 16:48:00 -0000 Message-ID: <20110722164852.15022.qmail@sourceware.org> From: jkratoch@sourceware.org To: archer-commits@sourceware.org Subject: [SCM] archer-jankratochvil-vla: Merge remote-tracking branch 'gdb/master' into archer-jankratochvil-vla X-Git-Refname: refs/heads/archer-jankratochvil-vla X-Git-Reftype: branch X-Git-Oldrev: e68ace2255f3503f3eb4281b9a1565f673918ca8 X-Git-Newrev: 1d2b1e48910b1b4f57f6c9fd9fefb7ccaa214429 X-SW-Source: 2011-q3/txt/msg00049.txt.bz2 List-Id: The branch, archer-jankratochvil-vla has been updated via 1d2b1e48910b1b4f57f6c9fd9fefb7ccaa214429 (commit) via 25993ce40950a8b34b31efd49790a16be3d5c519 (commit) via a9b3da94bae50d88a10d3158d7360e1545ccb8a7 (commit) via b002038111ddbace065011955f98fe50e8d0e794 (commit) via 7b0ba7e2d409d1864af5b32aa904895b1b0813d4 (commit) via a007d94a6a9ecfce3be7c7c08026aec697f08538 (commit) via 6e94ab2c3817f387d1b1621ad36575c710c09d6d (commit) via 87b5e086787b4a5396a303dd2e82fd9163edd8a4 (commit) via 712d52906e7877548df480f231f1ba45f2823d48 (commit) via b722ec47091f14953af30fcb159aac1bfb50e87f (commit) via fdc07668d3f537cb1c77f96d1cb1c0ca5769a964 (commit) via 6ca636601466311802dfbc339485c16fab5bc77b (commit) via ab80d2f364824d136e19c3161523b2308db1760d (commit) via 2adf90077dec6c3dcb421383b45eadbc59230949 (commit) from e68ace2255f3503f3eb4281b9a1565f673918ca8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email. - Log ----------------------------------------------------------------- commit 1d2b1e48910b1b4f57f6c9fd9fefb7ccaa214429 Merge: e68ace2 25993ce Author: Jan Kratochvil Date: Fri Jul 22 18:48:41 2011 +0200 Merge remote-tracking branch 'gdb/master' into archer-jankratochvil-vla Conflicts: gdb/doc/observer.texi ----------------------------------------------------------------------- Summary of changes: bfd/version.h | 2 +- gdb/ChangeLog | 148 +++ gdb/Makefile.in | 34 +- gdb/NEWS | 15 +- gdb/amd64-tdep.c | 37 +- gdb/common/buffer.c | 144 +++ gdb/common/buffer.h | 63 ++ gdb/common/common-utils.c | 170 +++ gdb/common/common-utils.h | 59 + gdb/{ => common}/gdb_assert.h | 0 gdb/{ => common}/gdb_dirent.h | 0 gdb/{ => common}/gdb_locale.h | 0 gdb/common/linux-osdata.c | 586 ++++++++++ gdb/{gdb_dirent.h => common/linux-osdata.h} | 36 +- gdb/common/ptid.c | 94 ++ gdb/common/ptid.h | 87 ++ gdb/common/xml-utils.c | 91 ++ gdb/{gdb_dirent.h => common/xml-utils.h} | 34 +- gdb/config/alpha/alpha-linux.mh | 2 +- gdb/config/arm/linux.mh | 3 +- gdb/config/i386/linux.mh | 2 +- gdb/config/i386/linux64.mh | 3 +- gdb/config/ia64/linux.mh | 3 +- gdb/config/m32r/linux.mh | 2 +- gdb/config/m68k/linux.mh | 3 +- gdb/config/mips/linux.mh | 2 +- gdb/config/pa/linux.mh | 4 +- gdb/config/powerpc/linux.mh | 2 +- gdb/config/powerpc/ppc64-linux.mh | 2 +- gdb/config/s390/s390.mh | 3 +- gdb/config/sparc/linux.mh | 2 +- gdb/config/sparc/linux64.mh | 2 +- gdb/config/xtensa/linux.mh | 3 +- gdb/defs.h | 70 +-- gdb/doc/ChangeLog | 12 + gdb/doc/gdb.texinfo | 33 +- gdb/doc/observer.texi | 5 + gdb/event-top.c | 107 ++- gdb/event-top.h | 3 - gdb/findvar.c | 24 +- gdb/gdbarch.c | 33 + gdb/gdbarch.h | 11 + gdb/gdbarch.sh | 5 + gdb/gdbserver/ChangeLog | 39 + gdb/gdbserver/Makefile.in | 35 +- gdb/gdbserver/config.in | 15 + gdb/gdbserver/configure | 159 +++ gdb/gdbserver/configure.ac | 1 + gdb/gdbserver/configure.srv | 32 +- gdb/gdbserver/inferiors.c | 82 -- gdb/gdbserver/linux-low.c | 316 +------ gdb/gdbserver/remote-utils.c | 164 --- gdb/gdbserver/server.c | 1 - gdb/gdbserver/server.h | 136 +--- gdb/gdbserver/utils.c | 77 +-- gdb/i386-tdep.c | 59 +- gdb/i386-tdep.h | 9 +- gdb/inferior.h | 32 +- gdb/infrun.c | 73 -- gdb/linux-nat.c | 142 +--- gdb/macrocmd.c | 133 ++- gdb/macrotab.c | 6 +- gdb/macrotab.h | 9 +- gdb/python/python.c | 80 ++ gdb/regcache.c | 55 + gdb/regcache.h | 6 + gdb/sentinel-frame.c | 15 +- gdb/symtab.c | 1 + gdb/testsuite/ChangeLog | 22 + gdb/testsuite/gdb.base/info-macros.c | 73 ++ gdb/testsuite/gdb.base/info-macros.exp | 202 ++++ gdb/testsuite/gdb.dwarf2/typeddwarf-amd64.S | 1568 +++++++++++++++++++++++++++ gdb/testsuite/gdb.dwarf2/typeddwarf.c | 2 +- gdb/testsuite/gdb.dwarf2/typeddwarf.exp | 23 +- gdb/testsuite/gdb.python/python.exp | 82 ++ gdb/testsuite/gdb.threads/Makefile.in | 3 +- gdb/top.c | 107 ++- gdb/top.h | 20 +- gdb/tui/tui-interp.c | 10 +- gdb/utils.c | 146 +--- gdb/version.in | 2 +- gdb/xml-support.c | 66 +-- gdb/xml-support.h | 6 +- include/ChangeLog | 28 + include/libiberty.h | 5 +- libiberty/ChangeLog | 12 + libiberty/Makefile.in | 19 +- libiberty/config.in | 6 + libiberty/configure | 12 +- libiberty/configure.ac | 12 +- libiberty/stack-limit.c | 59 + 91 files changed, 4553 insertions(+), 1550 deletions(-) create mode 100644 gdb/common/buffer.c create mode 100644 gdb/common/buffer.h create mode 100644 gdb/common/common-utils.c create mode 100644 gdb/common/common-utils.h rename gdb/{ => common}/gdb_assert.h (100%) copy gdb/{ => common}/gdb_dirent.h (100%) rename gdb/{ => common}/gdb_locale.h (100%) create mode 100644 gdb/common/linux-osdata.c copy gdb/{gdb_dirent.h => common/linux-osdata.h} (51%) create mode 100644 gdb/common/ptid.c create mode 100644 gdb/common/ptid.h create mode 100644 gdb/common/xml-utils.c rename gdb/{gdb_dirent.h => common/xml-utils.h} (53%) create mode 100644 gdb/testsuite/gdb.base/info-macros.c create mode 100644 gdb/testsuite/gdb.base/info-macros.exp create mode 100644 gdb/testsuite/gdb.dwarf2/typeddwarf-amd64.S create mode 100644 libiberty/stack-limit.c First 500 lines of diff: diff --git a/bfd/version.h b/bfd/version.h index bb223a4..c262ff7 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -1,4 +1,4 @@ -#define BFD_VERSION_DATE 20110720 +#define BFD_VERSION_DATE 20110722 #define BFD_VERSION @bfd_version@ #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@ #define REPORT_BUGS_TO @report_bugs_to@ diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5e4ab8c..37214d3 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,151 @@ +2011-07-22 Tom Tromey + + * amd64-tdep.c (amd64_pseudo_register_read_value): Rename + from amd64_pseudo_register_read. Change arguments. Call + mark_value_bytes_unavailable when needed. + (amd64_init_abi): Use set_gdbarch_pseudo_register_read_value, not + set_gdbarch_pseudo_register_read. + * sentinel-frame.c (sentinel_frame_prev_register): Use + regcache_cooked_read_value. + * regcache.h (regcache_cooked_read_value): Declare. + * regcache.c (regcache_cooked_read_value): New function. + (regcache_cooked_read): Call + gdbarch_pseudo_register_read_value if available. + * i386-tdep.h (i386_pseudo_register_read_value): Declare. + (i386_pseudo_register_read): Remove. + * i386-tdep.c (i386_pseudo_register_read_into_value): Rename from + i386_pseudo_register_read. Change arguments. Call + mark_value_bytes_unavailable when needed. + (i386_pseudo_register_read_value): New function. + (i386_gdbarch_init): Call set_gdbarch_pseudo_register_read_value, + not set_gdbarch_pseudo_register_read. + * gdbarch.sh (pseudo_register_read_value): New method. + * gdbarch.c, gdbarch.h: Rebuild. + * findvar.c (value_from_register): Call get_frame_register_value. + +2011-07-22 Phil Muldoon + + * event-top.c (cli_command_loop): Use get_prompt, get_suffix, + get_prefix. + (display_gdb_prompt): Likewise. + (change_annotation_level): Likewise. + (push_prompt): Likewise. + (pop_prompt): Likewise. + (handle_stop_sig): Use get_prompt with a level. + * top.c (command_loop): Use get_prompt with a level. + (set_async_annotation_level): Use set_prompt with a level. + (get_prefix): New function. + (set_prefix): Ditto. + (set_suffix): Ditto. + (get_suffix): Ditto. + (get_prompt): Accept a level argument. + (set_prompt): Accept a level argument. Free old prompts. Set + new_async_prompt if level is 0. + (init_main): Use set_prompt with a level. Do not set + new_async_prompt. + * event-top.h (PROMPT, SUFFIX, PREFIX): Move to top.c + * top.h: Declare set_suffix, get_suffix, set_prefix, get_prefix. + Modify set_prompt, get_prompt to account for levels. + * tui/tui-interp.c (tui_command_loop): Use get_prompt with a + level. + * python/python.c (before_prompt_hook): Use set_prompt. + +2011-07-22 Kwok Cheung Yeung + + * defs.h: Add guard against inclusion in gdbserver. + (struct ptid, ptid_t): Move to common/ptid.h. + (xfree, xzalloc, xasprintf, xvasprintf, xstrprintf, xstrvprintf, + xsnprintf, internal_error): Move to common/common-utils.h. + (nomem): Delete. + * gdb_assert.h: Move into common/ sub-directory. + * gdb_locale.h: Ditto. + * gdb_dirent.h: Ditto. + * inferior.h (minus_one_ptid, null_ptid, ptid_build, pid_to_ptid, + ptid_get_pid, ptid_get_lwp, ptid_get_tid, ptid_equal, ptid_is_pid): + Move into common/ptid.h. + * xml-support.c (xml_escape_text): Move into common/xml-utils.c. + (gdb_xml_create_parser_and_cleanup_1, xml_fetch_context_from_file): + Change nomem to malloc_failure. + * xml-support.h (xml_escape_text): Move into common/xml-utils.h. + * utils.c (nomem): Rename to malloc_failure. + (xmalloc, xzalloc, xrealloc, xcalloc, xfree, xstrprintf, xasprintf, + xvasprintf, xstrvprintf, xsnprintf): Move to common/common-utils.c. + (gdb_buildargv): Change nomem to malloc_failure. + * infrun.c (null_ptid, minus_one_ptid, ptid_build, pid_to_ptid, + ptid_get_pid, ptid_get_lwp, ptid_get_tid, ptid_equal, + ptid_is_pid): Move into common/ptid.c. + (initialize_infrun): Delete initialization of null_ptid and + minus_one_ptid. + * linux-nat.c (linux_nat_xfer_osdata): Defer to + linux_common_xfer_osdata. + * Makefile.in (SFILES): Add common/common-utils.c, common/xml-utils.c, + common/ptid.c and common/buffer.c. + (HFILES_NO_SRCDIR): Add common/common-utils.h, common/xml-utils.h, + common/ptid.h, common/buffer.h and common/linux-osdata.h. + (COMMON_OBS): Add xml-utils.o, common-utils.o, buffer.o and ptid.o. + (common-utils.o, xml-utils.o, ptid.o, buffer.o, linux-osdata.o): New + rules. + * common/gdb_assert.h: New. + * common/gdb_dirent.h: New. + * common/gdb_locale.h: New. + * common/buffer.c: New. + * common/buffer.h: New. + * common/ptid.c: New. + * common/ptid.h: New. + * common/xml-utils.c: New. + * common/xml-utils.h: New. + * common/common-utils.c: New. + * common/common-utils.h: New. + * common/linux-osdata.c: New. + * common/linux-osdata.h: New. + * config/alpha/alpha-linux.mh (NATDEPFILES): Add linux-osdata.o. + * config/arm/linux.mh (NATDEPFILES): Ditto. + * config/i386/linux.mh (NATDEPFILES): Ditto. + * config/i386/linux64.mh (NATDEPFILES): Ditto. + * config/ia64/linux.mh (NATDEPFILES): Ditto. + * config/m32r/linux.mh (NATDEPFILES): Ditto. + * config/m68k/linux.mh (NATDEPFILES): Ditto. + * config/mips/linux.mh (NATDEPFILES): Ditto. + * config/pa/linux.mh (NATDEPFILES): Ditto. + * config/powerpc/linux.mh (NATDEPFILES): Ditto. + * config/powerpc/ppc64-linux.mh (NATDEPFILES): Ditto. + * config/s390/s390.mh (NATDEPFILES): Ditto. + * config/sparc/linux.mh (NATDEPFILES): Ditto. + * config/sparc/linux64.mh (NATDEPFILES): Ditto. + * config/xtensa/linux.mh (NATDEPFILES): Ditto. + +2011-07-21 Matt Rice + + * NEWS: Add info macros and info definitions commands. + +2011-07-21 Phil Muldoon + + * NEWS: Document Python prompt substitution hook. + +2011-07-18 Matt Rice + + PR macros/12999 + * macrotab.h (macro_callback_fn): Add new arguments to callback. + * macrotab.c (foreach_macro): Ditto. + (foreach_macro_in_scope): Ditto. + * macrocmd.c (print_macro_callback): New function. + (info_macro_command): Move some code to print_macro_definition. + (print_macro_definition): New function. + (print_one_macro): Add new arguments to callback. + (info_definitions_command): New function. + (info_macros_command): Ditto. + (_initialize_macrocmd): Add info macros and info definitions commands. + * symtab.c (add_macro_name): Add new arguments to callback. + +2011-07-21 Phil Muldoon + Tom Tromey + + * top.c (set_prompt): Rewrite to free previous prompt, free + asynch_new_prompt and set both on new prompts. + * event-top.c (display_gdb_prompt): Add prompt substitution + logic. + * python/python.c (before_prompt_hook): New function. + 2011-07-20 Matt Rice * bfin-tdep.c (bfin_extract_return_value): Fix swapped diff --git a/gdb/Makefile.in b/gdb/Makefile.in index 494f24f..46593e3 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -737,7 +737,9 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \ jit.c \ xml-syscall.c \ annotate.c common/signals.c copying.c dfp.c gdb.c inf-child.c \ - regset.c sol-thread.c windows-termcap.c + regset.c sol-thread.c windows-termcap.c \ + common/common-utils.c common/xml-utils.c \ + common/ptid.c common/buffer.c LINTFILES = $(SFILES) $(YYFILES) $(CONFIG_SRCS) init.c @@ -816,7 +818,9 @@ osdata.h procfs.h python/py-event.h python/py-events.h python/py-stopevent.h \ python/python-internal.h python/python.h ravenscar-thread.h record.h \ solib-darwin.h solib-ia64-hpux.h solib-spu.h windows-nat.h xcoffread.h \ gnulib/extra/arg-nonnull.h gnulib/extra/c++defs.h gnulib/extra/warn-on-use.h \ -gnulib/stddef.in.h inline-frame.h +gnulib/stddef.in.h inline-frame.h \ +common/common-utils.h common/xml-utils.h common/buffer.h common/ptid.h \ +common/linux-osdata.h # Header files that already have srcdir in them, or which are in objdir. @@ -898,10 +902,12 @@ COMMON_OBS = $(DEPFILES) $(CONFIG_OBS) $(YYOBJ) \ trad-frame.o \ tramp-frame.o \ solib.o solib-target.o \ - prologue-value.o memory-map.o memrange.o xml-support.o xml-syscall.o \ + prologue-value.o memory-map.o memrange.o \ + xml-support.o xml-syscall.o xml-utils.o \ target-descriptions.o target-memory.o xml-tdesc.o xml-builtin.o \ inferior.o osdata.o gdb_usleep.o record.o gcore.o \ - jit.o progspace.o + jit.o progspace.o \ + common-utils.o buffer.o ptid.o TSOBS = inflow.o @@ -1933,6 +1939,26 @@ signals.o: $(srcdir)/common/signals.c $(COMPILE) $(srcdir)/common/signals.c $(POSTCOMPILE) +common-utils.o: ${srcdir}/common/common-utils.c + $(COMPILE) $(srcdir)/common/common-utils.c + $(POSTCOMPILE) + +xml-utils.o: ${srcdir}/common/xml-utils.c + $(COMPILE) $(srcdir)/common/xml-utils.c + $(POSTCOMPILE) + +ptid.o: ${srcdir}/common/ptid.c + $(COMPILE) $(srcdir)/common/ptid.c + $(POSTCOMPILE) + +buffer.o: ${srcdir}/common/buffer.c + $(COMPILE) $(srcdir)/common/buffer.c + $(POSTCOMPILE) + +linux-osdata.o: ${srcdir}/common/linux-osdata.c + $(COMPILE) $(srcdir)/common/linux-osdata.c + $(POSTCOMPILE) + # # gdb/tui/ dependencies # diff --git a/gdb/NEWS b/gdb/NEWS index 22d5a9c..263b70b 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,10 +3,15 @@ *** Changes since GDB 7.3 -* The "maint set python print-stack on|off" command has been - deprecated, and a new command: "set python print-stack on|off" has - replaced it. Additionally, the default for "print-stack" is now - "off". +* Python scripting + + ** The "maint set python print-stack on|off" command has been + deprecated, and a new command: "set python print-stack on|off" has + replaced it. Additionally, the default for "print-stack" is now + "off". + + ** A prompt subsitution hook (prompt_hook) is now available to the + Python API. * libthread-db-search-path now supports two special values: $sdir and $pdir. $sdir specifies the default system locations of shared libraries. @@ -40,6 +45,8 @@ the first connection is made. The listening port used by GDBserver will become available after that. +* New commands "info macros", and "info definitions" have been added. + * Changed commands watch EXPRESSION mask MASK_VALUE diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index de62ac7..051fb13 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -275,14 +275,21 @@ amd64_pseudo_register_name (struct gdbarch *gdbarch, int regnum) return i386_pseudo_register_name (gdbarch, regnum); } -static enum register_status -amd64_pseudo_register_read (struct gdbarch *gdbarch, - struct regcache *regcache, - int regnum, gdb_byte *buf) +static struct value * +amd64_pseudo_register_read_value (struct gdbarch *gdbarch, + struct regcache *regcache, + int regnum) { gdb_byte raw_buf[MAX_REGISTER_SIZE]; struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); enum register_status status; + struct value *result_value; + gdb_byte *buf; + + result_value = allocate_value (register_type (gdbarch, regnum)); + VALUE_LVAL (result_value) = lval_register; + VALUE_REGNUM (result_value) = regnum; + buf = value_contents_raw (result_value); if (i386_byte_regnum_p (gdbarch, regnum)) { @@ -297,15 +304,19 @@ amd64_pseudo_register_read (struct gdbarch *gdbarch, raw_buf); if (status == REG_VALID) memcpy (buf, raw_buf + 1, 1); + else + mark_value_bytes_unavailable (result_value, 0, + TYPE_LENGTH (value_type (result_value))); } else { status = regcache_raw_read (regcache, gpnum, raw_buf); if (status == REG_VALID) memcpy (buf, raw_buf, 1); + else + mark_value_bytes_unavailable (result_value, 0, + TYPE_LENGTH (value_type (result_value))); } - - return status; } else if (i386_dword_regnum_p (gdbarch, regnum)) { @@ -314,11 +325,15 @@ amd64_pseudo_register_read (struct gdbarch *gdbarch, status = regcache_raw_read (regcache, gpnum, raw_buf); if (status == REG_VALID) memcpy (buf, raw_buf, 4); - - return status; + else + mark_value_bytes_unavailable (result_value, 0, + TYPE_LENGTH (value_type (result_value))); } else - return i386_pseudo_register_read (gdbarch, regcache, regnum, buf); + i386_pseudo_register_read_into_value (gdbarch, regcache, regnum, + result_value); + + return result_value; } static void @@ -2494,8 +2509,8 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) /* Avoid wiring in the MMX registers for now. */ tdep->num_mmx_regs = 0; - set_gdbarch_pseudo_register_read (gdbarch, - amd64_pseudo_register_read); + set_gdbarch_pseudo_register_read_value (gdbarch, + amd64_pseudo_register_read_value); set_gdbarch_pseudo_register_write (gdbarch, amd64_pseudo_register_write); diff --git a/gdb/common/buffer.c b/gdb/common/buffer.c new file mode 100644 index 0000000..4ada0bc --- /dev/null +++ b/gdb/common/buffer.c @@ -0,0 +1,144 @@ +/* A simple growing buffer for GDB. + + Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifdef GDBSERVER +#include "server.h" +#else +#include "defs.h" +#endif + +#include "xml-utils.h" +#include "buffer.h" + +#include +#include +#include + +void +buffer_grow (struct buffer *buffer, const char *data, size_t size) +{ + char *new_buffer; + size_t new_buffer_size; + + if (size == 0) + return; + + new_buffer_size = buffer->buffer_size; + + if (new_buffer_size == 0) + new_buffer_size = 1; + + while (buffer->used_size + size > new_buffer_size) + new_buffer_size *= 2; + new_buffer = xrealloc (buffer->buffer, new_buffer_size); + if (!new_buffer) + abort (); + memcpy (new_buffer + buffer->used_size, data, size); + buffer->buffer = new_buffer; + buffer->buffer_size = new_buffer_size; + buffer->used_size += size; +} + +void +buffer_free (struct buffer *buffer) +{ + if (!buffer) + return; + + xfree (buffer->buffer); + buffer->buffer = NULL; + buffer->buffer_size = 0; + buffer->used_size = 0; +} + +void +buffer_init (struct buffer *buffer) +{ + memset (buffer, 0, sizeof (*buffer)); +} + +char* +buffer_finish (struct buffer *buffer) +{ + char *ret = buffer->buffer; + buffer->buffer = NULL; + buffer->buffer_size = 0; + buffer->used_size = 0; + return ret; +} + +void +buffer_xml_printf (struct buffer *buffer, const char *format, ...) +{ + va_list ap; + const char *f; + const char *prev; + int percent = 0; + + va_start (ap, format); + + prev = format; + for (f = format; *f; f++) + { + if (percent) + { + char buf[32]; + char *p; + char *str = buf; + + switch (*f) + { + case 's': + str = va_arg (ap, char *); + break; + case 'd': + sprintf (str, "%d", va_arg (ap, int)); + break; + case 'u': + sprintf (str, "%u", va_arg (ap, unsigned int)); + break; + case 'x': + sprintf (str, "%x", va_arg (ap, unsigned int)); + break; + case 'o': + sprintf (str, "%o", va_arg (ap, unsigned int)); + break; + default: + str = 0; + break; + } + + if (str) + { + buffer_grow (buffer, prev, f - prev - 1); + p = xml_escape_text (str); + buffer_grow_str (buffer, p); + xfree (p); + prev = f + 1; + } + percent = 0; + } + else if (*f == '%') + percent = 1; + } + + buffer_grow_str (buffer, prev); + va_end (ap); +} + diff --git a/gdb/common/buffer.h b/gdb/common/buffer.h hooks/post-receive -- Repository for Project Archer.