1/* 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#include "param.h" 26 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. */ 41struct fetch_context *fetch_arg_init(enum tof type, struct process *proc, 42 struct arg_type_info *ret_info); 43 44/* Make a clone of context. */ 45struct fetch_context *fetch_arg_clone(struct process *proc, 46 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, 52 struct process *proc, 53 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, 58 struct process *proc, 59 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 65/* 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 73 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. */ 77struct fetch_context *arch_fetch_arg_init(enum tof type, struct process *proc, 78 struct arg_type_info *ret_info); 79struct fetch_context *arch_fetch_arg_clone(struct process *proc, 80 struct fetch_context *context); 81int arch_fetch_arg_next(struct fetch_context *ctx, enum tof type, 82 struct process *proc, struct arg_type_info *info, 83 struct value *valuep); 84int arch_fetch_retval(struct fetch_context *ctx, enum tof type, 85 struct process *proc, struct arg_type_info *info, 86 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 95#endif /* FETCH_H */ 96