blob: 3a1644aeeb88e7e51f6ee198eaef02b1efa64474 [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"
Petr Machatae36298a2012-09-13 17:12:41 +020025#include "param.h"
Petr Machataf6ec08a2012-01-06 16:58:54 +010026
27/* XXX isn't SYSCALL TOF just a different ABI? Maybe we needed to
28 * support variant ABIs all along. */
29enum tof {
30 LT_TOF_FUNCTION, /* A real library function */
31 LT_TOF_FUNCTIONR, /* Return from a real library function */
32 LT_TOF_SYSCALL, /* A syscall */
33 LT_TOF_SYSCALLR, /* Return from a syscall */
34};
35
36/* The contents of the structure is defined by the back end. */
37struct fetch_context;
38
39/* Initialize argument fetching. Returns NULL on failure. RET_INFO
40 * is the return type of the function. */
Petr Machata929bd572012-12-17 03:20:34 +010041struct fetch_context *fetch_arg_init(enum tof type, struct process *proc,
Petr Machataf6ec08a2012-01-06 16:58:54 +010042 struct arg_type_info *ret_info);
43
44/* Make a clone of context. */
Petr Machata929bd572012-12-17 03:20:34 +010045struct fetch_context *fetch_arg_clone(struct process *proc,
Petr Machataf6ec08a2012-01-06 16:58:54 +010046 struct fetch_context *context);
47
48/* Load next argument. The function returns 0 on success or a
49 * negative value on failure. The extracted value is stored in
50 * *VALUEP. */
51int fetch_arg_next(struct fetch_context *context, enum tof type,
Petr Machata929bd572012-12-17 03:20:34 +010052 struct process *proc,
Petr Machataf6ec08a2012-01-06 16:58:54 +010053 struct arg_type_info *info, struct value *valuep);
54
55/* Load return value. The function returns 0 on success or a negative
56 * value on failure. The extracted value is stored in *VALUEP. */
57int fetch_retval(struct fetch_context *context, enum tof type,
Petr Machata929bd572012-12-17 03:20:34 +010058 struct process *proc,
Petr Machataf6ec08a2012-01-06 16:58:54 +010059 struct arg_type_info *info, struct value *valuep);
60
61/* Destroy fetch context. CONTEXT shall be the same memory location
62 * that was passed to fetch_arg_next. */
63void fetch_arg_done(struct fetch_context *context);
64
Petr Machatae36298a2012-09-13 17:12:41 +020065/* Called before fetching arguments that come from parameter packs.
66 * Returns 0 on success or a negative value on failure. */
67int fetch_param_pack_start(struct fetch_context *context,
68 enum param_pack_flavor ppflavor);
69
70/* Called after a parameter pack has been fetched. */
71void fetch_param_pack_end(struct fetch_context *context);
72
Petr Machata311358a2012-09-22 15:24:06 +020073
74/* The following callbacks have to be implemented in backend if arch.h
75 * defines ARCH_HAVE_FETCH_ARG. These backend callbacks correspond to
76 * above functions. */
Petr Machata929bd572012-12-17 03:20:34 +010077struct fetch_context *arch_fetch_arg_init(enum tof type, struct process *proc,
Petr Machata311358a2012-09-22 15:24:06 +020078 struct arg_type_info *ret_info);
Petr Machata929bd572012-12-17 03:20:34 +010079struct fetch_context *arch_fetch_arg_clone(struct process *proc,
Petr Machata311358a2012-09-22 15:24:06 +020080 struct fetch_context *context);
81int arch_fetch_arg_next(struct fetch_context *ctx, enum tof type,
Petr Machata929bd572012-12-17 03:20:34 +010082 struct process *proc, struct arg_type_info *info,
Petr Machata311358a2012-09-22 15:24:06 +020083 struct value *valuep);
84int arch_fetch_retval(struct fetch_context *ctx, enum tof type,
Petr Machata929bd572012-12-17 03:20:34 +010085 struct process *proc, struct arg_type_info *info,
Petr Machata311358a2012-09-22 15:24:06 +020086 struct value *valuep);
87void arch_fetch_arg_done(struct fetch_context *context);
88
89/* The following callbacks have to be implemented in backend if arch.h
90 * defines ARCH_HAVE_FETCH_ARG and ARCH_HAVE_FETCH_PACK. */
91int arch_fetch_param_pack_start(struct fetch_context *context,
92 enum param_pack_flavor ppflavor);
93void arch_fetch_param_pack_end(struct fetch_context *context);
94
Petr Machataf6ec08a2012-01-06 16:58:54 +010095#endif /* FETCH_H */