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,
{
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));
}
{
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));
}
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)
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));
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));
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));
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));
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));
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;
}
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);
}
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. */
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);
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)
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)
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)"),
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;
}
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;
}
{
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;
}
}
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)
{
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);
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));
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));
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);
}
}
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);
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;
}
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;
}
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;
}
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);
{
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)
{
/* 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);
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);
}