blob: 6a5385ca66f785806c61d40bf98862d46eea7922 [file] [log] [blame]
Petr Machataf6ec08a2012-01-06 16:58:54 +01001/*
2 * This file is part of ltrace.
3 * Copyright (C) 2011,2012 Petr Machata, Red Hat Inc.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18 * 02110-1301 USA
19 */
20
21#ifndef FETCH_H
22#define FETCH_H
23
24#include "forward.h"
25
26/* XXX isn't SYSCALL TOF just a different ABI? Maybe we needed to
27 * support variant ABIs all along. */
28enum tof {
29 LT_TOF_FUNCTION, /* A real library function */
30 LT_TOF_FUNCTIONR, /* Return from a real library function */
31 LT_TOF_SYSCALL, /* A syscall */
32 LT_TOF_SYSCALLR, /* Return from a syscall */
33};
34
35/* The contents of the structure is defined by the back end. */
36struct fetch_context;
37
38/* Initialize argument fetching. Returns NULL on failure. RET_INFO
39 * is the return type of the function. */
40struct fetch_context *fetch_arg_init(enum tof type, struct Process *proc,
41 struct arg_type_info *ret_info);
42
43/* Make a clone of context. */
44struct fetch_context *fetch_arg_clone(struct Process *proc,
45 struct fetch_context *context);
46
47/* Load next argument. The function returns 0 on success or a
48 * negative value on failure. The extracted value is stored in
49 * *VALUEP. */
50int fetch_arg_next(struct fetch_context *context, enum tof type,
51 struct Process *proc,
52 struct arg_type_info *info, struct value *valuep);
53
54/* Load return value. The function returns 0 on success or a negative
55 * value on failure. The extracted value is stored in *VALUEP. */
56int fetch_retval(struct fetch_context *context, enum tof type,
57 struct Process *proc,
58 struct arg_type_info *info, struct value *valuep);
59
60/* Destroy fetch context. CONTEXT shall be the same memory location
61 * that was passed to fetch_arg_next. */
62void fetch_arg_done(struct fetch_context *context);
63
64#endif /* FETCH_H */