28#include "gdbsupport/filestuff.h"
32#include "elf/common.h"
44 const gdb_byte *writebuf,
51 std::string pathname = string_printf (
"/proc/%d/auxv",
inferior_ptid.pid ());
53 = gdb_open_cloexec (pathname, writebuf != NULL ? O_WRONLY : O_RDONLY, 0);
57 if (offset != (ULONGEST) 0
58 && lseek (fd.get (), (off_t) offset,
SEEK_SET) != (off_t) offset)
60 else if (readbuf != NULL)
61 l =
read (fd.get (), readbuf, (
size_t) len);
63 l = write (fd.get (), writebuf, (
size_t) len);
71 *xfered_len = (ULONGEST) l;
80 const gdb_byte *writebuf,
82 ULONGEST len, ULONGEST *xfered_len)
85 CORE_ADDR data_address, pointer_address;
87 size_t ptr_size = ptr_type->
length ();
88 size_t auxv_pair_size = 2 * ptr_size;
89 gdb_byte *ptr_buf = (gdb_byte *) alloca (ptr_size);
133 if (data_address == 0)
136 data_address += offset;
138 if (writebuf != NULL)
142 *xfered_len = (ULONGEST) len;
152 if (offset >= auxv_pair_size)
164 gdb_assert (
block % auxv_pair_size == 0);
176 block &= -auxv_pair_size;
182 if (
block <= auxv_pair_size)
185 block = auxv_pair_size;
189 data_address +=
block;
196 while (
block >= auxv_pair_size)
198 retval += auxv_pair_size;
202 *xfered_len = (ULONGEST) retval;
206 readbuf += auxv_pair_size;
207 block -= auxv_pair_size;
211 *xfered_len = (ULONGEST) retval;
223 const gdb_byte *writebuf,
225 ULONGEST len, ULONGEST *xfered_len)
228 gdb_assert (readbuf || writebuf);
254 const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp,
255 int sizeof_auxv_type)
258 const int sizeof_auxv_val = ptr_type->
length ();
260 const gdb_byte *ptr = *readptr;
265 if (endptr - ptr < 2 * sizeof_auxv_val)
273 ptr += sizeof_auxv_val;
275 ptr += sizeof_auxv_val;
285 const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
289 const int sizeof_auxv_type = ptr_type->
length ();
299 const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
302 const int sizeof_auxv_type = int_type->
length ();
319 const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
324 return ops->
auxv_parse (readptr, endptr, typep, valp);
333 gdb::optional<gdb::byte_vector>
data;
359const gdb::optional<gdb::byte_vector> &
376gdb::optional<gdb::byte_vector>
389 const gdb_byte *data = auxv.data ();
390 const gdb_byte *ptr = data;
391 size_t len = auxv.size ();
417 if (!auxv.has_value ())
429 CORE_ADDR
type, CORE_ADDR val)
432 plongest (
type),
name, description);
446 if (opts.addressprint)
449 NULL, val, -1, file, &opts);
460 CORE_ADDR
type, CORE_ADDR val)
462 const char *
name =
"???";
463 const char *description =
"";
468#define TAG(tag, text, kind) \
469 case tag: name = #tag; description = text; format = kind; break
487 TAG (AT_HWCAP, _(
"Machine-dependent CPU capability hints"),
494 TAG (AT_BASE_PLATFORM, _(
"String identifying base platform"),
498 TAG (AT_RSEQ_FEATURE_SIZE, _(
"rseq supported feature size"),
500 TAG (AT_RSEQ_ALIGN, _(
"rseq allocation alignment"),
505 TAG (AT_SYSINFO_EHDR, _(
"System-supplied DSO's ELF header"),
507 TAG (AT_L1I_CACHESHAPE, _(
"L1 Instruction cache information"),
510 TAG (AT_L1I_CACHEGEOMETRY, _(
"L1 Instruction cache geometry"),
514 TAG (AT_L1D_CACHEGEOMETRY, _(
"L1 Data cache geometry"),
522 TAG (AT_MINSIGSTKSZ, _(
"Minimum stack size for signal delivery"),
529 TAG (AT_SUN_LDSHDR, _(
"Dynamic linker's section headers"),
531 TAG (AT_SUN_LDNAME, _(
"String giving name of dynamic linker"),
535 TAG (AT_SUN_CAP_HW1, _(
"Machine-dependent CPU capability hints"),
540 TAG (AT_SUN_EMUL_EXECFD, _(
"COFF executable file descriptor"),
542 TAG (AT_SUN_EXECNAME,
545 TAG (AT_SUN_LDDATA, _(
"Dynamic linker's data segment address"),
547 TAG (AT_SUN_AUXFLAGS,
549 TAG (AT_SUN_EMULATOR, _(
"Name of emulation binary for runtime linker"),
552 TAG (AT_SUN_BRAND_AUX1, _(
"Aux vector for brand modules 1"),
554 TAG (AT_SUN_BRAND_AUX2, _(
"Aux vector for brand modules 2"),
556 TAG (AT_SUN_BRAND_AUX3, _(
"Aux vector for brand modules 3"),
558 TAG (AT_SUN_CAP_HW2, _(
"Machine-dependent CPU capability hints 2"),
575 if (!auxv.has_value ())
578 const gdb_byte *data = auxv->data ();
579 const gdb_byte *ptr = data;
580 size_t len = auxv->size ();
584 &ptr, data + len, &
type, &val) > 0)
599 error (_(
"The program has no auxiliary information now."));
605 error (_(
"No auxiliary vector found, or failed reading it."));
607 error (_(
"Auxiliary vector is empty."));
616 _(
"Display the inferior's auxiliary vector.\n\
617This is information provided by the operating system at program startup."));
struct gdbarch * target_gdbarch(void)
static void info_auxv_command(const char *cmd, int from_tty)
static const registry< inferior >::key< auxv_info > auxv_inferior_data
static void auxv_all_objfiles_removed(program_space *pspace)
int default_auxv_parse(struct target_ops *ops, const gdb_byte **readptr, const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
int target_auxv_search(const gdb::byte_vector &auxv, target_ops *ops, gdbarch *gdbarch, CORE_ADDR match, CORE_ADDR *valp)
const gdb::optional< gdb::byte_vector > & target_read_auxv()
#define TAG(tag, text, kind)
static int parse_auxv(target_ops *ops, gdbarch *gdbarch, const gdb_byte **readptr, const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
void fprint_auxv_entry(struct ui_file *file, const char *name, const char *description, enum auxv_format format, CORE_ADDR type, CORE_ADDR val)
static int generic_auxv_parse(struct gdbarch *gdbarch, const gdb_byte **readptr, const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp, int sizeof_auxv_type)
static void invalidate_auxv_cache_inf(struct inferior *inf)
int svr4_auxv_parse(struct gdbarch *gdbarch, const gdb_byte **readptr, const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
static enum target_xfer_status ld_so_xfer_auxv(gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
void default_print_auxv_entry(struct gdbarch *gdbarch, struct ui_file *file, CORE_ADDR type, CORE_ADDR val)
gdb::optional< gdb::byte_vector > target_read_auxv_raw(target_ops *ops)
static int fprint_target_auxv(struct ui_file *file)
static enum target_xfer_status procfs_xfer_auxv(gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
target_xfer_partial_ftype memory_xfer_auxv
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
ssize_t read(int fd, void *buf, size_t count)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
int gdbarch_auxv_parse(struct gdbarch *gdbarch, const gdb_byte **readptr, const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
void gdbarch_print_auxv_entry(struct gdbarch *gdbarch, struct ui_file *file, CORE_ADDR type, CORE_ADDR val)
bool gdbarch_auxv_parse_p(struct gdbarch *gdbarch)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
struct inferior * current_inferior(void)
all_inferiors_range all_inferiors(process_stratum_target *proc_target=nullptr)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
observable< struct inferior * > inferior_exit
observable< program_space * > all_objfiles_removed
observable< struct inferior * > inferior_appeared
struct program_space * current_program_space
gdb::optional< gdb::byte_vector > data
CORE_ADDR value_address() const
struct minimal_symbol * minsym
struct type * builtin_data_ptr
struct type * builtin_int
unsigned long size() const
virtual int auxv_parse(const gdb_byte **readptr, const gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp) TARGET_DEFAULT_FUNC(default_auxv_parse)
int target_write_memory(CORE_ADDR memaddr, const gdb_byte *myaddr, ssize_t len)
gdb::optional< gdb::byte_vector > target_read_alloc(struct target_ops *ops, enum target_object object, const char *annex)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void gdb_printf(struct ui_file *stream, const char *format,...)
int val_print_string(struct type *elttype, const char *encoding, CORE_ADDR addr, int len, struct ui_file *stream, const struct value_print_options *options)
void get_user_print_options(struct value_print_options *opts)