15796c8dcSSimon Schubert /* Signal trampoline unwinder. 25796c8dcSSimon Schubert 3*ef5ccd6cSJohn Marino Copyright (C) 2004-2013 Free Software Foundation, Inc. 45796c8dcSSimon Schubert 55796c8dcSSimon Schubert This file is part of GDB. 65796c8dcSSimon Schubert 75796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 85796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 95796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 105796c8dcSSimon Schubert (at your option) any later version. 115796c8dcSSimon Schubert 125796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 135796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 145796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 155796c8dcSSimon Schubert GNU General Public License for more details. 165796c8dcSSimon Schubert 175796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 185796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 195796c8dcSSimon Schubert 205796c8dcSSimon Schubert #ifndef TRAMP_FRAME_H 215796c8dcSSimon Schubert #define TRAMP_FRAME_H 225796c8dcSSimon Schubert 235796c8dcSSimon Schubert #include "frame.h" /* For "enum frame_type". */ 245796c8dcSSimon Schubert 255796c8dcSSimon Schubert struct trad_frame; 265796c8dcSSimon Schubert struct frame_info; 275796c8dcSSimon Schubert struct trad_frame_cache; 285796c8dcSSimon Schubert 295796c8dcSSimon Schubert /* A trampoline consists of a small sequence of instructions placed at 305796c8dcSSimon Schubert an unspecified location in the inferior's address space. The only 315796c8dcSSimon Schubert identifying attribute of the trampoline's address is that it does 325796c8dcSSimon Schubert not fall inside an object file's section. 335796c8dcSSimon Schubert 345796c8dcSSimon Schubert The only way to identify a trampoline is to perform a brute force 355796c8dcSSimon Schubert examination of the instructions at and around the PC. 365796c8dcSSimon Schubert 375796c8dcSSimon Schubert This module provides a convenient interface for performing that 385796c8dcSSimon Schubert operation. */ 395796c8dcSSimon Schubert 405796c8dcSSimon Schubert /* A trampoline descriptor. */ 415796c8dcSSimon Schubert 425796c8dcSSimon Schubert /* Magic instruction that to mark the end of the signal trampoline 435796c8dcSSimon Schubert instruction sequence. */ 445796c8dcSSimon Schubert #define TRAMP_SENTINEL_INSN ((LONGEST) -1) 455796c8dcSSimon Schubert 465796c8dcSSimon Schubert struct tramp_frame 475796c8dcSSimon Schubert { 485796c8dcSSimon Schubert /* The trampoline's type, some a signal trampolines, some are normal 495796c8dcSSimon Schubert call-frame trampolines (aka thunks). */ 505796c8dcSSimon Schubert enum frame_type frame_type; 515796c8dcSSimon Schubert /* The trampoline's entire instruction sequence. It consists of a 525796c8dcSSimon Schubert bytes/mask pair. Search for this in the inferior at or around 535796c8dcSSimon Schubert the frame's PC. It is assumed that the PC is INSN_SIZE aligned, 545796c8dcSSimon Schubert and that each element of TRAMP contains one INSN_SIZE 555796c8dcSSimon Schubert instruction. It is also assumed that INSN[0] contains the first 565796c8dcSSimon Schubert instruction of the trampoline and hence the address of the 575796c8dcSSimon Schubert instruction matching INSN[0] is the trampoline's "func" address. 585796c8dcSSimon Schubert The instruction sequence is terminated by 595796c8dcSSimon Schubert TRAMP_SENTINEL_INSN. */ 605796c8dcSSimon Schubert int insn_size; 615796c8dcSSimon Schubert struct 625796c8dcSSimon Schubert { 635796c8dcSSimon Schubert ULONGEST bytes; 645796c8dcSSimon Schubert ULONGEST mask; 655796c8dcSSimon Schubert } insn[48]; 665796c8dcSSimon Schubert /* Initialize a trad-frame cache corresponding to the tramp-frame. 675796c8dcSSimon Schubert FUNC is the address of the instruction TRAMP[0] in memory. */ 685796c8dcSSimon Schubert void (*init) (const struct tramp_frame *self, 695796c8dcSSimon Schubert struct frame_info *this_frame, 705796c8dcSSimon Schubert struct trad_frame_cache *this_cache, 715796c8dcSSimon Schubert CORE_ADDR func); 725796c8dcSSimon Schubert }; 735796c8dcSSimon Schubert 745796c8dcSSimon Schubert void tramp_frame_prepend_unwinder (struct gdbarch *gdbarch, 755796c8dcSSimon Schubert const struct tramp_frame *tramp); 765796c8dcSSimon Schubert 775796c8dcSSimon Schubert #endif 78