2 * This file is part of ltrace.
3 * Copyright (C) 2011,2012 Petr Machata, Red Hat Inc.
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.
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.
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
29 #ifdef ARCH_HAVE_FETCH_ARG
30 struct fetch_context *arch_fetch_arg_init(enum tof type, struct process *proc,
31 struct arg_type_info *ret_info);
33 struct fetch_context *arch_fetch_arg_clone(struct process *proc,
34 struct fetch_context *context);
36 int arch_fetch_arg_next(struct fetch_context *ctx, enum tof type,
37 struct process *proc, struct arg_type_info *info,
38 struct value *valuep);
40 int arch_fetch_retval(struct fetch_context *ctx, enum tof type,
41 struct process *proc, struct arg_type_info *info,
42 struct value *valuep);
44 void arch_fetch_arg_done(struct fetch_context *context);
46 # ifdef ARCH_HAVE_FETCH_PACK
47 int arch_fetch_param_pack_start(struct fetch_context *context,
48 enum param_pack_flavor ppflavor);
50 void arch_fetch_param_pack_end(struct fetch_context *context);
54 /* Fall back to gimme_arg. */
56 long gimme_arg(enum tof type, struct process *proc, int arg_num,
57 struct arg_type_info *info);
59 struct fetch_context {
63 struct fetch_context *
64 arch_fetch_arg_init(enum tof type, struct process *proc,
65 struct arg_type_info *ret_info)
67 return calloc(sizeof(struct fetch_context), 1);
70 struct fetch_context *
71 arch_fetch_arg_clone(struct process *proc, struct fetch_context *context)
73 struct fetch_context *ret = malloc(sizeof(*ret));
76 return memcpy(ret, context, sizeof(*ret));
80 arch_fetch_arg_next(struct fetch_context *context, enum tof type,
82 struct arg_type_info *info, struct value *valuep)
84 long l = gimme_arg(type, proc, context->argnum++, info);
85 value_set_word(valuep, l);
90 arch_fetch_retval(struct fetch_context *context, enum tof type,
92 struct arg_type_info *info, struct value *valuep)
94 long l = gimme_arg(type, proc, -1, info);
95 value_set_word(valuep, l);
100 arch_fetch_arg_done(struct fetch_context *context)
106 #if !defined(ARCH_HAVE_FETCH_ARG) || !defined(ARCH_HAVE_FETCH_PACK)
108 arch_fetch_param_pack_start(struct fetch_context *context,
109 enum param_pack_flavor ppflavor)
115 arch_fetch_param_pack_end(struct fetch_context *context)
120 struct fetch_context *
121 fetch_arg_init(enum tof type, struct process *proc,
122 struct arg_type_info *ret_info)
124 return arch_fetch_arg_init(type, proc, ret_info);
127 struct fetch_context *
128 fetch_arg_clone(struct process *proc, struct fetch_context *context)
130 return arch_fetch_arg_clone(proc, context);
134 fetch_arg_next(struct fetch_context *context, enum tof type,
135 struct process *proc,
136 struct arg_type_info *info, struct value *valuep)
138 return arch_fetch_arg_next(context, type, proc, info, valuep);
142 fetch_retval(struct fetch_context *context, enum tof type,
143 struct process *proc,
144 struct arg_type_info *info, struct value *valuep)
146 return arch_fetch_retval(context, type, proc, info, valuep);
150 fetch_arg_done(struct fetch_context *context)
152 return arch_fetch_arg_done(context);
156 fetch_param_pack_start(struct fetch_context *context,
157 enum param_pack_flavor ppflavor)
159 return arch_fetch_param_pack_start(context, ppflavor);
163 fetch_param_pack_end(struct fetch_context *context)
165 return arch_fetch_param_pack_end(context);