2004-06-26 Andrew Cagney * xcoffsolib.c (xcoff_solib_address): Replace xasprintf with xstrprintf. * varobj.c (varobj_gen_name, create_child, c_name_of_child) (c_value_of_variable): Ditto. * utils.c (internal_vproblem): Ditto. * solib-aix5.c (build_so_list_from_mapfile): Ditto. * remote.c (add_packet_config_cmd): Ditto. * remote-rdp.c (rdp_set_command_line): Ditto. * regcache.c (regcache_dump): Ditto. * frv-tdep.c (new_variant, new_variant): Ditto. * fbsd-proc.c (child_pid_to_exec_file): Ditto. (fbsd_find_memory_regions): Ditto. * breakpoint.c (create_thread_event_breakpoint) (create_breakpoints): Ditto. * aix-thread.c (aix_thread_pid_to_str): Ditto. * ada-lang.c (is_package_name): Ditto. Also delete xmalloc call. Index: doc/ChangeLog 2004-06-26 Andrew Cagney * gdbint.texinfo (Coding): Replace xasprintf with xstrprintf. Index: ada-lang.c =================================================================== RCS file: /cvs/src/src/gdb/ada-lang.c,v retrieving revision 1.39 diff -p -u -r1.39 ada-lang.c --- ada-lang.c 18 Jun 2004 21:36:14 -0000 1.39 +++ ada-lang.c 26 Jun 2004 18:50:25 -0000 @@ -4371,8 +4371,7 @@ is_package_name (const char *name) if (strstr (name, "__") != NULL) return 0; - fun_name = (char *) alloca (strlen (name) + 5 + 1); - xasprintf (&fun_name, "_ada_%s", name); + fun_name = xstrprintf ("_ada_%s", name); return (standard_lookup (fun_name, NULL, VAR_DOMAIN) == NULL); } Index: aix-thread.c =================================================================== RCS file: /cvs/src/src/gdb/aix-thread.c,v retrieving revision 1.28 diff -p -u -r1.28 aix-thread.c --- aix-thread.c 13 May 2004 22:55:32 -0000 1.28 +++ aix-thread.c 26 Jun 2004 18:50:30 -0000 @@ -1629,10 +1629,10 @@ aix_thread_pid_to_str (ptid_t ptid) return base_target.to_pid_to_str (ptid); /* Free previous return value; a new one will be allocated by - xasprintf(). */ + xstrprintf(). */ xfree (ret); - xasprintf (&ret, "Thread %ld", ptid_get_tid (ptid)); + ret = xstrprintf ("Thread %ld", ptid_get_tid (ptid)); return ret; } Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.175 diff -p -u -r1.175 breakpoint.c --- breakpoint.c 22 Jun 2004 19:46:40 -0000 1.175 +++ breakpoint.c 26 Jun 2004 18:51:02 -0000 @@ -4258,7 +4258,7 @@ create_thread_event_breakpoint (CORE_ADD b->enable_state = bp_enabled; /* addr_string has to be used or breakpoint_re_set will delete me. */ - xasprintf (&b->addr_string, "*0x%s", paddr (b->loc->address)); + b->addr_string = xstrprintf ("*0x%s", paddr (b->loc->address)); return b; } @@ -4902,7 +4902,7 @@ create_breakpoints (struct symtabs_and_l else /* addr_string has to be used or breakpoint_re_set will delete me. */ - xasprintf (&b->addr_string, "*0x%s", paddr (b->loc->address)); + b->addr_string = xstrprintf ("*0x%s", paddr (b->loc->address)); b->cond_string = cond_string[i]; b->ignore_count = ignore_count; b->enable_state = bp_enabled; Index: fbsd-proc.c =================================================================== RCS file: /cvs/src/src/gdb/fbsd-proc.c,v retrieving revision 1.8 diff -p -u -r1.8 fbsd-proc.c --- fbsd-proc.c 30 May 2004 18:29:10 -0000 1.8 +++ fbsd-proc.c 26 Jun 2004 18:51:14 -0000 @@ -38,7 +38,7 @@ child_pid_to_exec_file (int pid) char *path; char *buf; - xasprintf (&path, "/proc/%d/file", pid); + path = xstrprintf ("/proc/%d/file", pid); buf = xcalloc (MAXPATHLEN, sizeof (char)); make_cleanup (xfree, path); make_cleanup (xfree, buf); @@ -82,7 +82,7 @@ fbsd_find_memory_regions (int (*func) (C char protection[4]; int read, write, exec; - xasprintf (&mapfilename, "/proc/%ld/map", (long) pid); + mapfilename = xstrprintf ("/proc/%ld/map", (long) pid); mapfile = fopen (mapfilename, "r"); if (mapfile == NULL) error ("Couldn't open %s\n", mapfilename); Index: frv-tdep.c =================================================================== RCS file: /cvs/src/src/gdb/frv-tdep.c,v retrieving revision 1.85 diff -p -u -r1.85 frv-tdep.c --- frv-tdep.c 20 Jun 2004 17:18:04 -0000 1.85 +++ frv-tdep.c 26 Jun 2004 18:57:58 -0000 @@ -197,7 +197,7 @@ new_variant (void) for (r = acc0_regnum; r <= acc7_regnum; r++) { char *buf; - xasprintf (&buf, "acc%d", r - acc0_regnum); + buf = xstrprintf ("acc%d", r - acc0_regnum); var->register_names[r] = buf; } @@ -210,7 +210,7 @@ new_variant (void) for (r = accg0_regnum; r <= accg7_regnum; r++) { char *buf; - xasprintf (&buf, "accg%d", r - accg0_regnum); + buf = xstrprintf ("accg%d", r - accg0_regnum); var->register_names[r] = buf; } Index: regcache.c =================================================================== RCS file: /cvs/src/src/gdb/regcache.c,v retrieving revision 1.114 diff -p -u -r1.114 regcache.c --- regcache.c 14 May 2004 07:17:45 -0000 1.114 +++ regcache.c 26 Jun 2004 18:58:05 -0000 @@ -1572,7 +1572,7 @@ regcache_dump (struct regcache *regcache char *n; if (!footnote_register_type_name_null) footnote_register_type_name_null = ++footnote_nr; - xasprintf (&n, "*%d", footnote_register_type_name_null); + n = xstrprintf ("*%d", footnote_register_type_name_null); make_cleanup (xfree, n); t = n; } Index: remote-rdp.c =================================================================== RCS file: /cvs/src/src/gdb/remote-rdp.c,v retrieving revision 1.38 diff -p -u -r1.38 remote-rdp.c --- remote-rdp.c 25 May 2004 14:58:30 -0000 1.38 +++ remote-rdp.c 26 Jun 2004 18:58:05 -0000 @@ -721,7 +721,7 @@ rdp_set_command_line (char *command, cha if (commandline != NULL) xfree (commandline); - xasprintf (&commandline, "%s %s", command, args); + commandline = xstrprintf ("%s %s", command, args); } static void Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.137 diff -p -u -r1.137 remote.c --- remote.c 15 Jun 2004 01:04:19 -0000 1.137 +++ remote.c 26 Jun 2004 18:58:28 -0000 @@ -651,12 +651,12 @@ add_packet_config_cmd (struct packet_con config->title = title; config->detect = AUTO_BOOLEAN_AUTO; config->support = PACKET_SUPPORT_UNKNOWN; - xasprintf (&set_doc, "Set use of remote protocol `%s' (%s) packet", - name, title); - xasprintf (&show_doc, "Show current use of remote protocol `%s' (%s) packet", - name, title); + set_doc = xstrprintf ("Set use of remote protocol `%s' (%s) packet", + name, title); + show_doc = xstrprintf ("Show current use of remote protocol `%s' (%s) packet", + name, title); /* set/show TITLE-packet {auto,on,off} */ - xasprintf (&cmd_name, "%s-packet", title); + cmd_name = xstrprintf ("%s-packet", title); add_setshow_auto_boolean_cmd (cmd_name, class_obscure, &config->detect, set_doc, show_doc, set_func, show_func, @@ -665,7 +665,7 @@ add_packet_config_cmd (struct packet_con if (legacy) { char *legacy_name; - xasprintf (&legacy_name, "%s-packet", name); + legacy_name = xstrprintf ("%s-packet", name); add_alias_cmd (legacy_name, cmd_name, class_obscure, 0, set_remote_list); add_alias_cmd (legacy_name, cmd_name, class_obscure, 0, Index: solib-aix5.c =================================================================== RCS file: /cvs/src/src/gdb/solib-aix5.c,v retrieving revision 1.13 diff -p -u -r1.13 solib-aix5.c --- solib-aix5.c 23 Jan 2002 06:24:20 -0000 1.13 +++ solib-aix5.c 26 Jun 2004 18:58:29 -0000 @@ -193,7 +193,7 @@ build_so_list_from_mapfile (int pid, lon /* Open the map file */ - xasprintf (&map_pathname, "/proc/%d/map", pid); + map_pathname = xstrprintf ("/proc/%d/map", pid); map_fd = open (map_pathname, O_RDONLY); xfree (map_pathname); if (map_fd < 0) Index: utils.c =================================================================== RCS file: /cvs/src/src/gdb/utils.c,v retrieving revision 1.121 diff -p -u -r1.121 utils.c --- utils.c 11 May 2004 19:19:34 -0000 1.121 +++ utils.c 26 Jun 2004 18:59:09 -0000 @@ -753,7 +753,7 @@ internal_vproblem (struct internal_probl { char *msg; xvasprintf (&msg, fmt, ap); - xasprintf (&reason, "\ + reason = xstrprintf ("\ %s:%d: %s: %s\n\ A problem internal to GDB has been detected,\n\ further debugging may prove unreliable.", file, line, problem->name, msg); Index: varobj.c =================================================================== RCS file: /cvs/src/src/gdb/varobj.c,v retrieving revision 1.40 diff -p -u -r1.40 varobj.c --- varobj.c 3 Sep 2003 20:46:02 -0000 1.40 +++ varobj.c 26 Jun 2004 18:59:20 -0000 @@ -549,7 +549,7 @@ varobj_gen_name (void) /* generate a name for this object */ id++; - xasprintf (&obj_name, "var%d", id); + obj_name = xstrprintf ("var%d", id); return obj_name; } @@ -1254,7 +1254,7 @@ create_child (struct varobj *parent, int child->error = 1; child->parent = parent; child->root = parent->root; - xasprintf (&childs_name, "%s.%s", parent->obj_name, name); + childs_name = xstrprintf ("%s.%s", parent->obj_name, name); child->obj_name = childs_name; install_variable (child); @@ -1837,7 +1837,7 @@ c_name_of_child (struct varobj *parent, switch (TYPE_CODE (type)) { case TYPE_CODE_ARRAY: - xasprintf (&name, "%d", index); + name = xstrprintf ("%d", index); break; case TYPE_CODE_STRUCT: @@ -1856,7 +1856,7 @@ c_name_of_child (struct varobj *parent, break; default: - xasprintf (&name, "*%s", parent->name); + name = xstrprintf ("*%s", parent->name); break; } break; @@ -2070,7 +2070,7 @@ c_value_of_variable (struct varobj *var) case TYPE_CODE_ARRAY: { char *number; - xasprintf (&number, "[%d]", var->num_children); + number = xstrprintf ("[%d]", var->num_children); return (number); } /* break; */ Index: xcoffsolib.c =================================================================== RCS file: /cvs/src/src/gdb/xcoffsolib.c,v retrieving revision 1.12 diff -p -u -r1.12 xcoffsolib.c --- xcoffsolib.c 9 Feb 2002 18:32:14 -0000 1.12 +++ xcoffsolib.c 26 Jun 2004 18:59:20 -0000 @@ -48,11 +48,11 @@ xcoff_solib_address (CORE_ADDR addr) if (vp->tstart <= addr && addr < vp->tend) { xfree (buffer); - xasprintf (&buffer, "%s%s%s%s", - vp->name, - *vp->member ? "(" : "", - vp->member, - *vp->member ? ")" : ""); + buffer = xstrprintf ("%s%s%s%s", + vp->name, + *vp->member ? "(" : "", + vp->member, + *vp->member ? ")" : ""); return buffer; } return NULL; Index: doc/gdbint.texinfo =================================================================== RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v retrieving revision 1.211 diff -p -u -r1.211 gdbint.texinfo --- doc/gdbint.texinfo 20 Jun 2004 17:18:07 -0000 1.211 +++ doc/gdbint.texinfo 26 Jun 2004 18:59:49 -0000 @@ -4942,7 +4942,7 @@ allocation of small temporary values (su restrict the memory being allocated to no more than a few kilobytes.} @value{GDBN} uses the string function @code{xstrdup} and the print -function @code{xasprintf}. +function @code{xstrprintf}. @emph{Pragmatics: @code{asprintf} and @code{strdup} can fail. Print functions such as @code{sprintf} are very prone to buffer overflow