xref: /dflybsd-src/contrib/gdb-7/gdb/exec.h (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* Work with executable files, for GDB, the GNU debugger.
25796c8dcSSimon Schubert 
3*ef5ccd6cSJohn Marino    Copyright (C) 2003-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 EXEC_H
215796c8dcSSimon Schubert #define EXEC_H
225796c8dcSSimon Schubert 
235796c8dcSSimon Schubert #include "target.h"
24cf7f2e2dSJohn Marino #include "progspace.h"
25c50c785cSJohn Marino #include "memrange.h"
265796c8dcSSimon Schubert 
275796c8dcSSimon Schubert struct target_section;
285796c8dcSSimon Schubert struct target_ops;
295796c8dcSSimon Schubert struct bfd;
305796c8dcSSimon Schubert 
315796c8dcSSimon Schubert extern struct target_ops exec_ops;
325796c8dcSSimon Schubert 
33cf7f2e2dSJohn Marino #define exec_bfd current_program_space->ebfd
34cf7f2e2dSJohn Marino #define exec_bfd_mtime current_program_space->ebfd_mtime
35*ef5ccd6cSJohn Marino #define exec_filename current_program_space->pspace_exec_filename
36cf7f2e2dSJohn Marino 
375796c8dcSSimon Schubert /* Builds a section table, given args BFD, SECTABLE_PTR, SECEND_PTR.
385796c8dcSSimon Schubert    Returns 0 if OK, 1 on error.  */
395796c8dcSSimon Schubert 
405796c8dcSSimon Schubert extern int build_section_table (struct bfd *, struct target_section **,
415796c8dcSSimon Schubert 				struct target_section **);
425796c8dcSSimon Schubert 
435796c8dcSSimon Schubert /* Resize the section table held by TABLE, by NUM_ADDED.  Returns the
445796c8dcSSimon Schubert    old size.  */
455796c8dcSSimon Schubert 
465796c8dcSSimon Schubert extern int resize_section_table (struct target_section_table *, int);
475796c8dcSSimon Schubert 
48c50c785cSJohn Marino /* Appends all read-only memory ranges found in the target section
49c50c785cSJohn Marino    table defined by SECTIONS and SECTIONS_END, starting at (and
50c50c785cSJohn Marino    intersected with) MEMADDR for LEN bytes.  Returns the augmented
51c50c785cSJohn Marino    VEC.  */
52c50c785cSJohn Marino 
53c50c785cSJohn Marino extern VEC(mem_range_s) *
54c50c785cSJohn Marino   section_table_available_memory (VEC(mem_range_s) *ranges,
55c50c785cSJohn Marino 				  CORE_ADDR memaddr, ULONGEST len,
56c50c785cSJohn Marino 				  struct target_section *sections,
57c50c785cSJohn Marino 				  struct target_section *sections_end);
58c50c785cSJohn Marino 
595796c8dcSSimon Schubert /* Read or write from mappable sections of BFD executable files.
605796c8dcSSimon Schubert 
615796c8dcSSimon Schubert    Request to transfer up to LEN 8-bit bytes of the target sections
625796c8dcSSimon Schubert    defined by SECTIONS and SECTIONS_END.  The OFFSET specifies the
635796c8dcSSimon Schubert    starting address.
645796c8dcSSimon Schubert    If SECTION_NAME is not NULL, only access sections with that same
655796c8dcSSimon Schubert    name.
665796c8dcSSimon Schubert 
675796c8dcSSimon Schubert    Return the number of bytes actually transfered, or zero when no
685796c8dcSSimon Schubert    data is available for the requested range.
695796c8dcSSimon Schubert 
705796c8dcSSimon Schubert    This function is intended to be used from target_xfer_partial
715796c8dcSSimon Schubert    implementations.  See target_read and target_write for more
725796c8dcSSimon Schubert    information.
735796c8dcSSimon Schubert 
745796c8dcSSimon Schubert    One, and only one, of readbuf or writebuf must be non-NULL.  */
755796c8dcSSimon Schubert 
765796c8dcSSimon Schubert extern int section_table_xfer_memory_partial (gdb_byte *, const gdb_byte *,
775796c8dcSSimon Schubert 					      ULONGEST, LONGEST,
785796c8dcSSimon Schubert 					      struct target_section *,
795796c8dcSSimon Schubert 					      struct target_section *,
805796c8dcSSimon Schubert 					      const char *);
815796c8dcSSimon Schubert 
825796c8dcSSimon Schubert /* Set the loaded address of a section.  */
835796c8dcSSimon Schubert extern void exec_set_section_address (const char *, int, CORE_ADDR);
845796c8dcSSimon Schubert 
855796c8dcSSimon Schubert /* Remove all target sections taken from ABFD.  */
865796c8dcSSimon Schubert 
87*ef5ccd6cSJohn Marino extern void remove_target_sections (void *key, bfd *abfd);
885796c8dcSSimon Schubert 
895796c8dcSSimon Schubert /* Add the sections array defined by [SECTIONS..SECTIONS_END[ to the
905796c8dcSSimon Schubert    current set of target sections.  */
915796c8dcSSimon Schubert 
92*ef5ccd6cSJohn Marino extern void add_target_sections (void *key,
93*ef5ccd6cSJohn Marino 				 struct target_section *sections,
945796c8dcSSimon Schubert 				 struct target_section *sections_end);
955796c8dcSSimon Schubert 
965796c8dcSSimon Schubert /* Prints info about all sections defined in the TABLE.  ABFD is
975796c8dcSSimon Schubert    special cased --- it's filename is omitted; if it is the executable
985796c8dcSSimon Schubert    file, its entry point is printed.  */
995796c8dcSSimon Schubert 
1005796c8dcSSimon Schubert extern void print_section_info (struct target_section_table *table,
1015796c8dcSSimon Schubert 				bfd *abfd);
1025796c8dcSSimon Schubert 
103cf7f2e2dSJohn Marino extern void exec_close (void);
1045796c8dcSSimon Schubert 
1055796c8dcSSimon Schubert #endif
106