xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/auxv.h (revision 8b657b0747480f8989760d71343d6dd33f8d4cf9)
1 /* Auxiliary vector support for GDB, the GNU debugger.
2 
3    Copyright (C) 2004-2023 Free Software Foundation, Inc.
4 
5    This file is part of GDB.
6 
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19 
20 #ifndef AUXV_H
21 #define AUXV_H
22 
23 #include "target.h"
24 
25 /* See "include/elf/common.h" for the definition of valid AT_* values.  */
26 
27 /* The default implementation of to_auxv_parse, used by the target
28    stack.
29 
30    Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
31    Return 0 if *READPTR is already at the end of the buffer.
32    Return -1 if there is insufficient buffer for a whole entry.
33    Return 1 if an entry was read into *TYPEP and *VALP.  */
34 extern int default_auxv_parse (struct target_ops *ops, const gdb_byte **readptr,
35 			       const gdb_byte *endptr, CORE_ADDR *typep,
36 			       CORE_ADDR *valp);
37 
38 /* The SVR4 psABI implementation of to_auxv_parse, that uses an int to
39    store the type rather than long as assumed by the default parser.
40 
41    Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
42    Return 0 if *READPTR is already at the end of the buffer.
43    Return -1 if there is insufficient buffer for a whole entry.
44    Return 1 if an entry was read into *TYPEP and *VALP.  */
45 extern int svr4_auxv_parse (struct gdbarch *gdbarch, const gdb_byte **readptr,
46 			    const gdb_byte *endptr, CORE_ADDR *typep,
47 			    CORE_ADDR *valp);
48 
49 /* Read auxv data from the current inferior's target stack.  */
50 
51 extern gdb::optional<gdb::byte_vector> target_read_auxv ();
52 
53 /* Read auxv data from OPS.  */
54 
55 extern gdb::optional<gdb::byte_vector> target_read_auxv_raw (target_ops *ops);
56 
57 /* Search AUXV for an entry with a_type matching MATCH.
58 
59    OPS and GDBARCH are the target and architecture to use to parse auxv entries.
60 
61    Return zero if no such entry was found, or -1 if there was
62    an error getting the information.  On success, return 1 after
63    storing the entry's value field in *VALP.  */
64 
65 extern int target_auxv_search (const gdb::byte_vector &auxv,
66 			       target_ops *ops, gdbarch *gdbarch,
67 			       CORE_ADDR match, CORE_ADDR *valp);
68 
69 /* Same as the above, but read the auxv data from the current inferior.  Use
70    the current inferior's top target and arch to parse auxv entries.  */
71 
72 extern int target_auxv_search (CORE_ADDR match, CORE_ADDR *valp);
73 
74 /* Print a description of a single AUXV entry on the specified file.  */
75 enum auxv_format { AUXV_FORMAT_DEC, AUXV_FORMAT_HEX, AUXV_FORMAT_STR };
76 
77 extern void fprint_auxv_entry (struct ui_file *file, const char *name,
78 			       const char *description,
79 			       enum auxv_format format, CORE_ADDR type,
80 			       CORE_ADDR val);
81 
82 /* The default implementation of gdbarch_print_auxv_entry.  */
83 
84 extern void default_print_auxv_entry (struct gdbarch *gdbarch,
85 				      struct ui_file *file, CORE_ADDR type,
86 				      CORE_ADDR val);
87 
88 extern target_xfer_partial_ftype memory_xfer_auxv;
89 
90 
91 #endif
92