/* Target-dependent code for UltraSPARC.
- Copyright (C) 2003-2018 Free Software Foundation, Inc.
+ Copyright (C) 2003-2020 Free Software Foundation, Inc.
This file is part of GDB.
static bool
adi_available (void)
{
- pid_t pid = ptid_get_pid (inferior_ptid);
+ pid_t pid = inferior_ptid.pid ();
sparc64_adi_info *proc = get_adi_info_proc (pid);
CORE_ADDR value;
return proc->stat.is_avail;
proc->stat.checked_avail = true;
- if (target_auxv_search (target_stack, AT_ADI_BLKSZ, &value) <= 0)
+ if (target_auxv_search (current_top_target (), AT_ADI_BLKSZ, &value) <= 0)
return false;
proc->stat.blksize = value;
- target_auxv_search (target_stack, AT_ADI_NBITS, &value);
+ target_auxv_search (current_top_target (), AT_ADI_NBITS, &value);
proc->stat.nbits = value;
proc->stat.max_version = (1 << proc->stat.nbits) - 2;
proc->stat.is_avail = true;
static CORE_ADDR
adi_normalize_address (CORE_ADDR addr)
{
- adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
+ adi_stat_t ast = get_adi_info (inferior_ptid.pid ());
if (ast.nbits)
{
static CORE_ADDR
adi_align_address (CORE_ADDR naddr)
{
- adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
+ adi_stat_t ast = get_adi_info (inferior_ptid.pid ());
return (naddr - (naddr % ast.blksize)) / ast.blksize;
}
static int
adi_convert_byte_count (CORE_ADDR naddr, int nbytes, CORE_ADDR locl)
{
- adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
+ adi_stat_t ast = get_adi_info (inferior_ptid.pid ());
return ((naddr + nbytes + ast.blksize - 1) / ast.blksize) - locl;
}
static int
adi_tag_fd (void)
{
- pid_t pid = ptid_get_pid (inferior_ptid);
+ pid_t pid = inferior_ptid.pid ();
sparc64_adi_info *proc = get_adi_info_proc (pid);
if (proc->stat.tag_fd != 0)
char filename[MAX_PROC_NAME_SIZE];
size_t i = 0;
- pid_t pid = ptid_get_pid (inferior_ptid);
+ pid_t pid = inferior_ptid.pid ();
snprintf (filename, sizeof filename, "/proc/%ld/adi/maps", (long) pid);
gdb::unique_xmalloc_ptr<char> data
= target_fileio_read_stralloc (NULL, filename);
if (data)
{
adi_stat_t adi_stat = get_adi_info (pid);
- char *line;
- for (line = strtok (data.get (), "\n"); line; line = strtok (NULL, "\n"))
+ char *saveptr;
+ for (char *line = strtok_r (data.get (), "\n", &saveptr);
+ line;
+ line = strtok_r (NULL, "\n", &saveptr))
{
ULONGEST addr, endaddr;
if (!adi_is_addr_mapped (vaddr, size))
{
- adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
+ adi_stat_t ast = get_adi_info (inferior_ptid.pid ());
error(_("Address at %s is not in ADI maps"),
paddress (target_gdbarch (), vaddr * ast.blksize));
}
if (!adi_is_addr_mapped (vaddr, size))
{
- adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
+ adi_stat_t ast = get_adi_info (inferior_ptid.pid ());
error(_("Address at %s is not in ADI maps"),
paddress (target_gdbarch (), vaddr * ast.blksize));
}
int v_idx = 0;
const int maxelts = 8; /* # of elements per line */
- adi_stat_t adi_stat = get_adi_info (ptid_get_pid (inferior_ptid));
+ adi_stat_t adi_stat = get_adi_info (inferior_ptid.pid ());
while (cnt > 0)
{
++v_idx;
}
printf_filtered ("\n");
- gdb_flush (gdb_stdout);
vaddr += maxelts;
}
}
Command syntax:
- adi (examine|x)/count <addr> */
+ adi (examine|x)[/COUNT] [ADDR] */
static void
adi_examine_command (const char *args, int from_tty)
if (!adi_available ())
error (_("No ADI information"));
- pid_t pid = ptid_get_pid (inferior_ptid);
- sparc64_adi_info *proc = get_adi_info_proc (pid);
int cnt = 1;
const char *p = args;
if (p && *p == '/')
if (p != 0 && *p != 0)
next_address = parse_and_eval_address (p);
if (!cnt || !next_address)
- error (_("Usage: adi examine|x[/count] <addr>"));
+ error (_("Usage: adi examine|x[/COUNT] [ADDR]"));
do_examine (next_address, cnt);
}
Command syntax:
- adi (assign|a)/count <addr> = <version> */
+ adi (assign|a)[/COUNT] ADDR = VERSION */
static void
adi_assign_command (const char *args, int from_tty)
{
+ static const char *adi_usage
+ = N_("Usage: adi assign|a[/COUNT] ADDR = VERSION");
+
/* make sure program is active and adi is available */
if (!target_has_execution)
error (_("ADI command requires a live process/thread"));
const char *exp = args;
if (exp == 0)
- error_no_arg (_("Usage: adi assign|a[/count] <addr> = <version>"));
+ error_no_arg (_(adi_usage));
char *q = (char *) strchr (exp, '=');
if (q)
*q++ = 0;
else
- error (_("Usage: adi assign|a[/count] <addr> = <version>"));
+ error ("%s", _(adi_usage));
size_t cnt = 1;
const char *p = args;
if (p != 0 && *p != 0)
next_address = parse_and_eval_address (p);
else
- error (_("Usage: adi assign|a[/count] <addr> = <version>"));
+ error ("%s", _(adi_usage));
int version = 0;
if (q != NULL) /* parse version tag */
{
- adi_stat_t ast = get_adi_info (ptid_get_pid (inferior_ptid));
+ adi_stat_t ast = get_adi_info (inferior_ptid.pid ());
version = parse_and_eval_long (q);
if (version < 0 || version > ast.max_version)
error (_("Invalid ADI version tag %d"), version);
/* Store floating fields of element ELEMENT of an "parameter array"
that has type TYPE and is stored at BITPOS in VALBUF in the
- apropriate registers of REGCACHE. This function can be called
+ appropriate registers of REGCACHE. This function can be called
recursively and therefore handles floating types in addition to
structures. */
static CORE_ADDR
sparc64_store_arguments (struct regcache *regcache, int nargs,
struct value **args, CORE_ADDR sp,
- int struct_return, CORE_ADDR struct_addr)
+ function_call_return_method return_method,
+ CORE_ADDR struct_addr)
{
struct gdbarch *gdbarch = regcache->arch ();
/* Number of extended words in the "parameter array". */
/* First we calculate the number of extended words in the "parameter
array". While doing so we also convert some of the arguments. */
- if (struct_return)
+ if (return_method == return_method_struct)
num_elements++;
for (i = 0; i < nargs; i++)
/* The psABI says that "Every stack frame must be 16-byte aligned." */
sp &= ~0xf;
- /* Now we store the arguments in to the "paramater array". Some
+ /* Now we store the arguments in to the "parameter array". Some
Integer or Pointer arguments and Structure or Union arguments
will be passed in %o registers. Some Floating arguments and
floating members of structures are passed in floating-point
contents of any unused memory or registers in the "parameter
array" are undefined. */
- if (struct_return)
+ if (return_method == return_method_struct)
{
regcache_cooked_write_unsigned (regcache, SPARC_O0_REGNUM, struct_addr);
element++;
sparc64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
struct regcache *regcache, CORE_ADDR bp_addr,
int nargs, struct value **args, CORE_ADDR sp,
- int struct_return, CORE_ADDR struct_addr)
+ function_call_return_method return_method,
+ CORE_ADDR struct_addr)
{
/* Set return address. */
regcache_cooked_write_unsigned (regcache, SPARC_O7_REGNUM, bp_addr - 8);
/* Set up function arguments. */
- sp = sparc64_store_arguments (regcache, nargs, args, sp,
- struct_return, struct_addr);
+ sp = sparc64_store_arguments (regcache, nargs, args, sp, return_method,
+ struct_addr);
/* Allocate the register save area. */
sp -= 16 * 8;