1130803Smarcel/* Auxiliary vector support for GDB, the GNU debugger.
2130803Smarcel
3130803Smarcel   Copyright 2004 Free Software Foundation, Inc.
4130803Smarcel
5130803Smarcel   This file is part of GDB.
6130803Smarcel
7130803Smarcel   This program is free software; you can redistribute it and/or modify
8130803Smarcel   it under the terms of the GNU General Public License as published by
9130803Smarcel   the Free Software Foundation; either version 2 of the License, or
10130803Smarcel   (at your option) any later version.
11130803Smarcel
12130803Smarcel   This program is distributed in the hope that it will be useful,
13130803Smarcel   but WITHOUT ANY WARRANTY; without even the implied warranty of
14130803Smarcel   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15130803Smarcel   GNU General Public License for more details.
16130803Smarcel
17130803Smarcel   You should have received a copy of the GNU General Public License
18130803Smarcel   along with this program; if not, write to the Free Software
19130803Smarcel   Foundation, Inc., 59 Temple Place - Suite 330,
20130803Smarcel   Boston, MA 02111-1307, USA.  */
21130803Smarcel
22130803Smarcel#ifndef AUXV_H
23130803Smarcel#define AUXV_H
24130803Smarcel
25130803Smarcel/* See "include/elf/common.h" for the definition of valid AT_* values.  */
26130803Smarcel
27130803Smarcel
28130803Smarcel/* Avoid miscellaneous includes in this file, so that it can be
29130803Smarcel   included by nm-*.h for the procfs_xfer_auxv decl if that is
30130803Smarcel   used in NATIVE_XFER_AUXV.  */
31130803Smarcelstruct target_ops;		/* Forward declaration.  */
32130803Smarcel
33130803Smarcel
34130803Smarcel/* Read all the auxv data into a contiguous xmalloc'd buffer,
35130803Smarcel   stored in *DATA.  Return the size in bytes of this data.
36130803Smarcel   If zero, there is no data and *DATA is null.
37130803Smarcel   if < 0, there was an error and *DATA is null.  */
38130803Smarcelextern LONGEST target_auxv_read (struct target_ops *ops, char **data);
39130803Smarcel
40130803Smarcel/* Read one auxv entry from *READPTR, not reading locations >= ENDPTR.
41130803Smarcel   Return 0 if *READPTR is already at the end of the buffer.
42130803Smarcel   Return -1 if there is insufficient buffer for a whole entry.
43130803Smarcel   Return 1 if an entry was read into *TYPEP and *VALP.  */
44130803Smarcelextern int target_auxv_parse (struct target_ops *ops,
45130803Smarcel			      char **readptr, char *endptr,
46130803Smarcel			      CORE_ADDR *typep, CORE_ADDR *valp);
47130803Smarcel
48130803Smarcel/* Extract the auxiliary vector entry with a_type matching MATCH.
49130803Smarcel   Return zero if no such entry was found, or -1 if there was
50130803Smarcel   an error getting the information.  On success, return 1 after
51130803Smarcel   storing the entry's value field in *VALP.  */
52130803Smarcelextern int target_auxv_search (struct target_ops *ops,
53130803Smarcel			       CORE_ADDR match, CORE_ADDR *valp);
54130803Smarcel
55130803Smarcel/* Print the contents of the target's AUXV on the specified file. */
56130803Smarcelextern int fprint_target_auxv (struct ui_file *file, struct target_ops *ops);
57130803Smarcel
58130803Smarcel
59130803Smarcel/* This function is called like a to_xfer_partial hook,
60130803Smarcel   but must be called with TARGET_OBJECT_AUXV.
61130803Smarcel   It handles access via /proc/PID/auxv, which is the common method.
62130803Smarcel   This function is appropriate for doing:
63130803Smarcel	   #define NATIVE_XFER_AUXV	procfs_xfer_auxv
64130803Smarcel   for a native target that uses inftarg.c's child_xfer_partial hook.  */
65130803Smarcel
66130803Smarcelextern LONGEST procfs_xfer_auxv (struct target_ops *ops,
67130803Smarcel				 int /* enum target_object */ object,
68130803Smarcel				 const char *annex,
69130803Smarcel				 void *readbuf,
70130803Smarcel				 const void *writebuf,
71130803Smarcel				 ULONGEST offset,
72130803Smarcel				 LONGEST len);
73130803Smarcel
74130803Smarcel
75130803Smarcel#endif
76