aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/arm-tdep.c17
-rw-r--r--gdb/breakpoint.c10
-rw-r--r--gdb/cli/cli-script.c16
-rw-r--r--gdb/dwarf2read.c3
-rw-r--r--gdb/gcore.c3
-rw-r--r--gdb/gnu-nat.c8
-rw-r--r--gdb/go32-nat.c6
-rw-r--r--gdb/interps.c4
-rw-r--r--gdb/m32c-tdep.c8
-rw-r--r--gdb/ppc-linux-nat.c8
-rw-r--r--gdb/remote-m32r-sdi.c6
-rw-r--r--gdb/sol-thread.c17
-rw-r--r--gdb/symtab.c7
-rw-r--r--gdb/tui/tui-io.c3
-rw-r--r--gdb/tui/tui-stack.c2
-rw-r--r--gdb/tui/tui-win.c4
16 files changed, 68 insertions, 54 deletions
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index a221fd6..8e96946 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3779,7 +3779,8 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
val + i * unit_length);
else
{
- sprintf (name_buf, "%c%d", reg_char, reg_scaled + i);
+ xsnprintf (name_buf, sizeof (name_buf), "%c%d",
+ reg_char, reg_scaled + i);
regnum = user_reg_map_name_to_regnum (gdbarch, name_buf,
strlen (name_buf));
regcache_cooked_write (regcache, regnum,
@@ -4110,7 +4111,7 @@ arm_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
{
char name_buf[4];
- sprintf (name_buf, "s%d", reg - 64);
+ xsnprintf (name_buf, sizeof (name_buf), "s%d", reg - 64);
return user_reg_map_name_to_regnum (gdbarch, name_buf,
strlen (name_buf));
}
@@ -4121,7 +4122,7 @@ arm_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
{
char name_buf[4];
- sprintf (name_buf, "d%d", reg - 256);
+ xsnprintf (name_buf, sizeof (name_buf), "d%d", reg - 256);
return user_reg_map_name_to_regnum (gdbarch, name_buf,
strlen (name_buf));
}
@@ -9169,7 +9170,7 @@ arm_return_value (struct gdbarch *gdbarch, struct value *function,
char name_buf[4];
int regnum;
- sprintf (name_buf, "%c%d", reg_char, i);
+ xsnprintf (name_buf, sizeof (name_buf), "%c%d", reg_char, i);
regnum = user_reg_map_name_to_regnum (gdbarch, name_buf,
strlen (name_buf));
if (writebuf)
@@ -9623,7 +9624,7 @@ arm_neon_quad_read (struct gdbarch *gdbarch, struct regcache *regcache,
int offset, double_regnum;
enum register_status status;
- sprintf (name_buf, "d%d", regnum << 1);
+ xsnprintf (name_buf, sizeof (name_buf), "d%d", regnum << 1);
double_regnum = user_reg_map_name_to_regnum (gdbarch, name_buf,
strlen (name_buf));
@@ -9675,7 +9676,7 @@ arm_pseudo_read (struct gdbarch *gdbarch, struct regcache *regcache,
else
offset = (regnum & 1) ? 4 : 0;
- sprintf (name_buf, "d%d", regnum >> 1);
+ xsnprintf (name_buf, sizeof (name_buf), "d%d", regnum >> 1);
double_regnum = user_reg_map_name_to_regnum (gdbarch, name_buf,
strlen (name_buf));
@@ -9700,7 +9701,7 @@ arm_neon_quad_write (struct gdbarch *gdbarch, struct regcache *regcache,
char name_buf[4];
int offset, double_regnum;
- sprintf (name_buf, "d%d", regnum << 1);
+ xsnprintf (name_buf, sizeof (name_buf), "d%d", regnum << 1);
double_regnum = user_reg_map_name_to_regnum (gdbarch, name_buf,
strlen (name_buf));
@@ -9741,7 +9742,7 @@ arm_pseudo_write (struct gdbarch *gdbarch, struct regcache *regcache,
else
offset = (regnum & 1) ? 4 : 0;
- sprintf (name_buf, "d%d", regnum >> 1);
+ xsnprintf (name_buf, sizeof (name_buf), "d%d", regnum >> 1);
double_regnum = user_reg_map_name_to_regnum (gdbarch, name_buf,
strlen (name_buf));
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 387ddb8..5749fa7 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -1024,9 +1024,10 @@ condition_completer (struct cmd_list_element *cmd, char *text, char *word)
char location[50];
if (single)
- sprintf (location, "%d", b->number);
+ xsnprintf (location, sizeof (location), "%d", b->number);
else
- sprintf (location, "%d.%d", b->number, count);
+ xsnprintf (location, sizeof (location), "%d.%d", b->number,
+ count);
if (strncmp (location, text, len) == 0)
VEC_safe_push (char_ptr, result, xstrdup (location));
@@ -15101,7 +15102,7 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
warning (_("Uploaded tracepoint %d has no "
"source location, using raw address"),
utp->number);
- sprintf (small_buf, "*%s", hex_string (utp->addr));
+ xsnprintf (small_buf, sizeof (small_buf), "*%s", hex_string (utp->addr));
addr_str = small_buf;
}
@@ -15132,7 +15133,8 @@ create_tracepoint_from_upload (struct uploaded_tp *utp)
if (utp->pass > 0)
{
- sprintf (small_buf, "%d %d", utp->pass, tp->base.number);
+ xsnprintf (small_buf, sizeof (small_buf), "%d %d", utp->pass,
+ tp->base.number);
trace_pass_command (small_buf, 0);
}
diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c
index 743c65f..6a31dd0 100644
--- a/gdb/cli/cli-script.c
+++ b/gdb/cli/cli-script.c
@@ -441,9 +441,10 @@ execute_control_command (struct command_line *cmd)
case while_control:
{
- char *buffer = alloca (strlen (cmd->line) + 7);
+ int len = strlen (cmd->line) + 7;
+ char *buffer = alloca (len);
- sprintf (buffer, "while %s", cmd->line);
+ xsnprintf (buffer, len, "while %s", cmd->line);
print_command_trace (buffer);
/* Parse the loop control expression for the while statement. */
@@ -509,9 +510,10 @@ execute_control_command (struct command_line *cmd)
case if_control:
{
- char *buffer = alloca (strlen (cmd->line) + 4);
+ int len = strlen (cmd->line) + 4;
+ char *buffer = alloca (len);
- sprintf (buffer, "if %s", cmd->line);
+ xsnprintf (buffer, len, "if %s", cmd->line);
print_command_trace (buffer);
new_line = insert_args (cmd->line);
@@ -1529,7 +1531,8 @@ define_command (char *comname, int from_tty)
if (isupper (*tem))
*tem = tolower (*tem);
- sprintf (tmpbuf, "Type commands for definition of \"%s\".", comfull);
+ xsnprintf (tmpbuf, sizeof (tmpbuf),
+ "Type commands for definition of \"%s\".", comfull);
cmds = read_command_lines (tmpbuf, from_tty, 1, 0, 0);
if (c && c->class == class_user)
@@ -1579,7 +1582,8 @@ document_command (char *comname, int from_tty)
if (c->class != class_user)
error (_("Command \"%s\" is built-in."), comfull);
- sprintf (tmpbuf, "Type documentation for \"%s\".", comfull);
+ xsnprintf (tmpbuf, sizeof (tmpbuf), "Type documentation for \"%s\".",
+ comfull);
doclines = read_command_lines (tmpbuf, from_tty, 0, 0, 0);
if (c->doc)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 078eb50..9ecdf4b 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -17903,7 +17903,8 @@ file_full_name (int file, struct line_header *lh, const char *comp_dir)
won't be able to find the file by name. */
char fake_name[80];
- sprintf (fake_name, "<bad macro file number %d>", file);
+ xsnprintf (fake_name, sizeof (fake_name),
+ "<bad macro file number %d>", file);
complaint (&symfile_complaints,
_("bad file number in macro information (%d)"),
diff --git a/gdb/gcore.c b/gdb/gcore.c
index 5667982..dadcf38 100644
--- a/gdb/gcore.c
+++ b/gdb/gcore.c
@@ -134,7 +134,8 @@ gcore_command (char *args, int from_tty)
else
{
/* Default corefile name is "core.PID". */
- sprintf (corefilename_buffer, "core.%d", PIDGET (inferior_ptid));
+ xsnprintf (corefilename_buffer, sizeof (corefilename_buffer),
+ "core.%d", PIDGET (inferior_ptid));
corefilename = corefilename_buffer;
}
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index e6836d7..1d74d04 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -2587,10 +2587,10 @@ proc_string (struct proc *proc)
static char tid_str[80];
if (proc_is_task (proc))
- sprintf (tid_str, "process %d", proc->inf->pid);
+ xsnprintf (tid_str, sizeof (tid_str), "process %d", proc->inf->pid);
else
- sprintf (tid_str, "Thread %d.%d",
- proc->inf->pid, proc->tid);
+ xsnprintf (tid_str, sizeof (tid_str), "Thread %d.%d",
+ proc->inf->pid, proc->tid);
return tid_str;
}
@@ -2607,7 +2607,7 @@ gnu_pid_to_str (struct target_ops *ops, ptid_t ptid)
{
static char tid_str[80];
- sprintf (tid_str, "bogus thread id %d", tid);
+ xsnprintf (tid_str, sizeof (tid_str), "bogus thread id %d", tid);
return tid_str;
}
}
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index ef1da91..befa75e 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -1273,9 +1273,9 @@ go32_sysinfo (char *arg, int from_tty)
break;
}
}
- sprintf (cpu_string, "%s%s Model %d Stepping %d",
- intel_p ? "Pentium" : (amd_p ? "AMD" : "ix86"),
- cpu_brand, cpu_model, cpuid_eax & 0xf);
+ xsnprintf (cpu_string, sizeof (cpu_string), "%s%s Model %d Stepping %d",
+ intel_p ? "Pentium" : (amd_p ? "AMD" : "ix86"),
+ cpu_brand, cpu_model, cpuid_eax & 0xf);
printfi_filtered (31, "%s\n", cpu_string);
if (((cpuid_edx & (6 | (0x0d << 23))) != 0)
|| ((cpuid_edx & 1) == 0)
diff --git a/gdb/interps.c b/gdb/interps.c
index 698e26e..fc14196 100644
--- a/gdb/interps.c
+++ b/gdb/interps.c
@@ -210,8 +210,8 @@ interp_set (struct interp *interp, int top_level)
{
if (!interp_quiet_p (interp))
{
- sprintf (buffer, "Switching to interpreter \"%.24s\".\n",
- interp->name);
+ xsnprintf (buffer, sizeof (buffer),
+ "Switching to interpreter \"%.24s\".\n", interp->name);
ui_out_text (current_uiout, buffer);
}
display_gdb_prompt (NULL);
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index b680fa0..f68fa4a 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -200,16 +200,16 @@ make_types (struct gdbarch *arch)
TYPE_UNSIGNED (tdep->ptr_voyd) = 1;
tdep->func_voyd = lookup_function_type (tdep->voyd);
- sprintf (type_name, "%s_data_addr_t",
- gdbarch_bfd_arch_info (arch)->printable_name);
+ xsnprintf (type_name, sizeof (type_name), "%s_data_addr_t",
+ gdbarch_bfd_arch_info (arch)->printable_name);
tdep->data_addr_reg_type
= arch_type (arch, TYPE_CODE_PTR, data_addr_reg_bits / TARGET_CHAR_BIT,
xstrdup (type_name));
TYPE_TARGET_TYPE (tdep->data_addr_reg_type) = tdep->voyd;
TYPE_UNSIGNED (tdep->data_addr_reg_type) = 1;
- sprintf (type_name, "%s_code_addr_t",
- gdbarch_bfd_arch_info (arch)->printable_name);
+ xsnprintf (type_name, sizeof (type_name), "%s_code_addr_t",
+ gdbarch_bfd_arch_info (arch)->printable_name);
tdep->code_addr_reg_type
= arch_type (arch, TYPE_CODE_PTR, code_addr_reg_bits / TARGET_CHAR_BIT,
xstrdup (type_name));
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index ef94a48..a2de188 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -601,8 +601,8 @@ fetch_register (struct regcache *regcache, int tid, int regno)
if (errno != 0)
{
char message[128];
- sprintf (message, "reading register %s (#%d)",
- gdbarch_register_name (gdbarch, regno), regno);
+ xsnprintf (message, sizeof (message), "reading register %s (#%d)",
+ gdbarch_register_name (gdbarch, regno), regno);
perror_with_name (message);
}
memcpy (&buf[bytes_transferred], &l, sizeof (l));
@@ -1095,8 +1095,8 @@ store_register (const struct regcache *regcache, int tid, int regno)
if (errno != 0)
{
char message[128];
- sprintf (message, "writing register %s (#%d)",
- gdbarch_register_name (gdbarch, regno), regno);
+ xsnprintf (message, sizeof (message), "writing register %s (#%d)",
+ gdbarch_register_name (gdbarch, regno), regno);
perror_with_name (message);
}
}
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index f7addea..c6ff539 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -376,14 +376,14 @@ m32r_open (char *args, int from_tty)
push_target (&m32r_ops);
if (args == NULL)
- sprintf (hostname, "localhost:%d", SDIPORT);
+ xsnprintf (hostname, sizeof (hostname), "localhost:%d", SDIPORT);
else
{
port_str = strchr (args, ':');
if (port_str == NULL)
- sprintf (hostname, "%s:%d", args, SDIPORT);
+ xsnprintf (hostname, sizeof (hostname), "%s:%d", args, SDIPORT);
else
- strcpy (hostname, args);
+ xsnprintf (hostname, sizeof (hostname), "%s", args);
}
sdi_desc = serial_open (hostname);
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index b2c1806..b627741 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -196,7 +196,8 @@ td_err_string (td_err_e errcode)
if (td_err_table[i].num == errcode)
return td_err_table[i].str;
- sprintf (buf, "Unknown libthread_db error code: %d", errcode);
+ xsnprintf (buf, sizeof (buf), "Unknown libthread_db error code: %d",
+ errcode);
return buf;
}
@@ -227,7 +228,8 @@ td_state_string (td_thr_state_e statecode)
if (td_thr_state_table[i].num == statecode)
return td_thr_state_table[i].str;
- sprintf (buf, "Unknown libthread_db state code: %d", statecode);
+ xsnprintf (buf, sizeof (buf), "Unknown libthread_db state code: %d",
+ statecode);
return buf;
}
@@ -1015,17 +1017,18 @@ solaris_pid_to_str (struct target_ops *ops, ptid_t ptid)
lwp = thread_to_lwp (ptid, -2);
if (PIDGET (lwp) == -1)
- sprintf (buf, "Thread %ld (defunct)", GET_THREAD (ptid));
+ xsnprintf (buf, sizeof (buf), "Thread %ld (defunct)",
+ GET_THREAD (ptid));
else if (PIDGET (lwp) != -2)
- sprintf (buf, "Thread %ld (LWP %ld)",
+ xsnprintf (buf, sizeof (buf), "Thread %ld (LWP %ld)",
GET_THREAD (ptid), GET_LWP (lwp));
else
- sprintf (buf, "Thread %ld ", GET_THREAD (ptid));
+ xsnprintf (buf, sizeof (buf), "Thread %ld ", GET_THREAD (ptid));
}
else if (GET_LWP (ptid) != 0)
- sprintf (buf, "LWP %ld ", GET_LWP (ptid));
+ xsnprintf (buf, sizeof (buf), "LWP %ld ", GET_LWP (ptid));
else
- sprintf (buf, "process %d ", PIDGET (ptid));
+ xsnprintf (buf, sizeof (buf), "process %d ", PIDGET (ptid));
return buf;
}
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 65542a7..05943cf 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -402,19 +402,20 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
if (len == 0)
{
- sprintf (buf, "__%s%s", const_prefix, volatile_prefix);
+ xsnprintf (buf, sizeof (buf), "__%s%s", const_prefix, volatile_prefix);
}
else if (physname[0] == 't' || physname[0] == 'Q')
{
/* The physname for template and qualified methods already includes
the class name. */
- sprintf (buf, "__%s%s", const_prefix, volatile_prefix);
+ xsnprintf (buf, sizeof (buf), "__%s%s", const_prefix, volatile_prefix);
newname = NULL;
len = 0;
}
else
{
- sprintf (buf, "__%s%s%d", const_prefix, volatile_prefix, len);
+ xsnprintf (buf, sizeof (buf), "__%s%s%d", const_prefix,
+ volatile_prefix, len);
}
mangled_name_len = ((is_constructor ? 0 : strlen (field_name))
+ strlen (buf) + len + strlen (physname) + 1);
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 29c1a2c..fe88f1a 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -419,7 +419,8 @@ tui_rl_display_match_list (char **matches, int len, int max)
{
char msg[256];
- sprintf (msg, "\nDisplay all %d possibilities? (y or n)", len);
+ xsnprintf (msg, sizeof (msg),
+ "\nDisplay all %d possibilities? (y or n)", len);
tui_puts (msg);
if (get_y_or_n () == 0)
{
diff --git a/gdb/tui/tui-stack.c b/gdb/tui/tui-stack.c
index 262a6bf..2cd6678 100644
--- a/gdb/tui/tui-stack.c
+++ b/gdb/tui/tui-stack.c
@@ -94,7 +94,7 @@ tui_make_status_line (struct tui_locator_element *loc)
/* Translate line number and obtain its size. */
if (loc->line_no > 0)
- sprintf (line_buf, "%d", loc->line_no);
+ xsnprintf (line_buf, sizeof (line_buf), "%d", loc->line_no);
else
strcpy (line_buf, "??");
line_width = strlen (line_buf);
diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index c12f036..f611f30 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -466,10 +466,10 @@ tui_update_gdb_sizes (void)
char cmd[50];
/* Set to TUI command window dimension or use readline values. */
- sprintf (cmd, "set width %d",
+ xsnprintf (cmd, sizeof (cmd), "set width %d",
tui_active ? TUI_CMD_WIN->generic.width : tui_term_width());
execute_command (cmd, 0);
- sprintf (cmd, "set height %d",
+ xsnprintf (cmd, sizeof (cmd), "set height %d",
tui_active ? TUI_CMD_WIN->generic.height : tui_term_height());
execute_command (cmd, 0);
}