Compare commits

...

11 Commits

Author SHA1 Message Date
Mike Frysinger
8d0317164e s 2022-11-11 01:44:13 +07:00
Mike Frysinger
7552a9f59e s:fdpic 2022-11-11 01:44:13 +07:00
Mike Frysinger
8d98f3c571 split FDPIC-specific logic out of FR-V code
The Blackfin port implements the FDPIC ABI the same way as the FR-V guys.
So rather than copy & paste their solib code, split it out into an FDPIC
solib file so people who implement it can use the same code.  SuperH will
probably use this file as well down the line.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2022-11-11 01:44:13 +07:00
Mike Frysinger
d022a4c7f5 gdbserver: split out elf/fdpic.h 2022-11-11 01:44:13 +07:00
Jie Zhang
864de6eaf5 gdb: bfin: add some Blackfin-specific tests
Not sure this is still needed ...

Signed-off-by: Jie Zhang <jie@codesourcery.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2022-11-11 01:44:13 +07:00
Jie Zhang
dd3115e159 gdb: adjust start address (why?)
Signed-off-by: Jie Zhang <jie@codesourcery.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2022-11-11 01:44:13 +07:00
Jie Zhang
4194556af5 gdb: add get_offsets hook
Signed-off-by: Jie Zhang <jie@codesourcery.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2022-11-11 01:44:13 +07:00
Jie Zhang
024e8f8c1e gdb: add convert_from_addr_func_ptr hook
Signed-off-by: Jie Zhang <jie@codesourcery.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2022-11-11 01:44:13 +07:00
Jie Zhang
4644fcb7fc gdb: tests: add support for testing FLAT toolchains
FLAT toolchains output a FLAT binary for the named output and create
another file with a .gdb suffix that is used for debugging.  So when
testing a FLAT toolchain and we need to load up a file, use the .gdb.

Signed-off-by: Jie Zhang <jie@codesourcery.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2022-11-11 01:44:12 +07:00
Mike Frysinger
714e2151f4 gdb: ignore test generated files 2022-11-11 01:44:12 +07:00
Mike Frysinger
1bb8d4214d gitignore: ignore site.{bak,exp} treewide
These files are never checked into cvs, and are generated by most
testsuites, so ignore them.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

2011-03-28  Mike Frysinger  <vapier@gentoo.org>

	* .gitignore: Ignore site.bak and site.exp.
2022-11-11 01:44:12 +07:00
23 changed files with 1784 additions and 1201 deletions

5
.gitignore vendored
View File

@@ -72,3 +72,8 @@ stamp-*
/mpc*
/gmp*
/isl*
site.bak
site.exp
*.log
*.sum

227
gdb/.gitignore vendored
View File

@@ -24,3 +24,230 @@
/observer.inc
/p-exp.c
/rust-exp.c
/testsuite/basic.tf
/testsuite/gdb.asm/arch.inc
/testsuite/gdb.asm/asm-source
/testsuite/gdb.asm/note.inc
/testsuite/gdb.base/.debug/
/testsuite/gdb.base/a2-run
/testsuite/gdb.base/advance
/testsuite/gdb.base/arrayidx
/testsuite/gdb.base/async
/testsuite/gdb.base/bang!
/testsuite/gdb.base/bfp-test
/testsuite/gdb.base/bitfields2
/testsuite/gdb.base/break-always
/testsuite/gdb.base/breako2
/testsuite/gdb.base/breakpoint-shadow
/testsuite/gdb.base/call-sc-tc
/testsuite/gdb.base/call-sc-td
/testsuite/gdb.base/call-sc-te
/testsuite/gdb.base/call-sc-tf
/testsuite/gdb.base/call-sc-ti
/testsuite/gdb.base/call-sc-tl
/testsuite/gdb.base/call-sc-tld
/testsuite/gdb.base/call-sc-tll
/testsuite/gdb.base/call-sc-ts
/testsuite/gdb.base/callexit
/testsuite/gdb.base/charset
/testsuite/gdb.base/complex
/testsuite/gdb.base/consecutive
/testsuite/gdb.base/cursal
/testsuite/gdb.base/cvexpr
/testsuite/gdb.base/del
/testsuite/gdb.base/dump
/testsuite/gdb.base/expand-psymtabs
/testsuite/gdb.base/find
/testsuite/gdb.base/finish
/testsuite/gdb.base/float
/testsuite/gdb.base/frame-args
/testsuite/gdb.base/freebpcmd
/testsuite/gdb.base/fullname
/testsuite/gdb.base/gcore
/testsuite/gdb.base/gcore-buffer-overflow-01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
/testsuite/gdb.base/gdb1090
/testsuite/gdb.base/gdb1250
/testsuite/gdb.base/gdb1821
/testsuite/gdb.base/gdbvars
/testsuite/gdb.base/hashline1
/testsuite/gdb.base/hashline1.c
/testsuite/gdb.base/hashline2
/testsuite/gdb.base/hashline2.c
/testsuite/gdb.base/hashline3
/testsuite/gdb.base/hashline3.c
/testsuite/gdb.base/hook-stop-continue
/testsuite/gdb.base/hook-stop-frame
/testsuite/gdb.base/huge
/testsuite/gdb.base/included
/testsuite/gdb.base/infnan
/testsuite/gdb.base/info-target
/testsuite/gdb.base/lineinc
/testsuite/gdb.base/longjmp
/testsuite/gdb.base/macscp
/testsuite/gdb.base/nofield
/testsuite/gdb.base/pc-fp
/testsuite/gdb.base/pr11022
/testsuite/gdb.base/prologue
/testsuite/gdb.base/psymtab
/testsuite/gdb.base/ptr-typedef
/testsuite/gdb.base/randomize
/testsuite/gdb.base/relational
/testsuite/gdb.base/remote
/testsuite/gdb.base/return-nodebug-int
/testsuite/gdb.base/return-nodebug-long
/testsuite/gdb.base/return-nodebug-long-long
/testsuite/gdb.base/return-nodebug-short
/testsuite/gdb.base/return-nodebug-signed-char
/testsuite/gdb.base/return2
/testsuite/gdb.base/sep
/testsuite/gdb.base/sepdebug
/testsuite/gdb.base/sepdebug.stripped
/testsuite/gdb.base/sepdebug2
/testsuite/gdb.base/sepdebug2.stripped
/testsuite/gdb.base/sepsymtab
/testsuite/gdb.base/sepsymtab.stripped
/testsuite/gdb.base/sizeof
/testsuite/gdb.base/stack-checking
/testsuite/gdb.base/start
/testsuite/gdb.base/step-break
/testsuite/gdb.base/step-bt
/testsuite/gdb.base/store
/testsuite/gdb.base/structs-tc
/testsuite/gdb.base/structs-tc-td
/testsuite/gdb.base/structs-tc-tf
/testsuite/gdb.base/structs-tc-ti
/testsuite/gdb.base/structs-tc-tl
/testsuite/gdb.base/structs-tc-tld
/testsuite/gdb.base/structs-tc-tll
/testsuite/gdb.base/structs-tc-ts
/testsuite/gdb.base/structs-td
/testsuite/gdb.base/structs-td-tc
/testsuite/gdb.base/structs-td-tf
/testsuite/gdb.base/structs-tf
/testsuite/gdb.base/structs-tf-tc
/testsuite/gdb.base/structs-tf-td
/testsuite/gdb.base/structs-ti
/testsuite/gdb.base/structs-ti-tc
/testsuite/gdb.base/structs-tl
/testsuite/gdb.base/structs-tl-tc
/testsuite/gdb.base/structs-tld
/testsuite/gdb.base/structs-tld-tc
/testsuite/gdb.base/structs-tll
/testsuite/gdb.base/structs-tll-tc
/testsuite/gdb.base/structs-ts
/testsuite/gdb.base/structs-ts-tc
/testsuite/gdb.base/structs3
/testsuite/gdb.base/symbol-without-target_section
/testsuite/gdb.base/tmp-fullname.c
/testsuite/gdb.base/until
/testsuite/gdb.base/valgrind-db-attach
/testsuite/gdb.base/value-double-free
/testsuite/gdb.base/volatile
/testsuite/gdb.base/watch-cond
/testsuite/gdb.base/watch-non-mem
/testsuite/gdb.base/watch-read
/testsuite/gdb.base/watchpoint-cond-gone
/testsuite/gdb.base/watchpoints
/testsuite/gdb.base/whatis-exp
/testsuite/gdb.cp/abstract-origin
/testsuite/gdb.cp/annota3
/testsuite/gdb.cp/arg-reference
/testsuite/gdb.cp/bool
/testsuite/gdb.cp/breakpoint
/testsuite/gdb.cp/bs15503
/testsuite/gdb.cp/call-c
/testsuite/gdb.cp/casts
/testsuite/gdb.cp/class2
/testsuite/gdb.cp/classes
/testsuite/gdb.cp/cpexprs
/testsuite/gdb.cp/exception
/testsuite/gdb.cp/expand-sals
/testsuite/gdb.cp/extern-c
/testsuite/gdb.cp/formatted-ref
/testsuite/gdb.cp/gdb1355
/testsuite/gdb.cp/hang
/testsuite/gdb.cp/m-data
/testsuite/gdb.cp/m-static
/testsuite/gdb.cp/mb-ctor
/testsuite/gdb.cp/mb-inline
/testsuite/gdb.cp/mb-templates
/testsuite/gdb.cp/namespace-nested-import
/testsuite/gdb.cp/nsdecl
/testsuite/gdb.cp/nsimport
/testsuite/gdb.cp/nsrecurs
/testsuite/gdb.cp/nsstress
/testsuite/gdb.cp/nsusing
/testsuite/gdb.cp/pass-by-ref
/testsuite/gdb.cp/pr-1023
/testsuite/gdb.cp/pr-1210
/testsuite/gdb.cp/pr-574
/testsuite/gdb.cp/pr10728
/testsuite/gdb.cp/pr9631
/testsuite/gdb.cp/printmethod
/testsuite/gdb.cp/psmang
/testsuite/gdb.cp/rtti
/testsuite/gdb.cp/shadow
/testsuite/gdb.cp/try_catch
/testsuite/gdb.cp/virtbase
/testsuite/gdb.dwarf2/dw2-noloc
/testsuite/gdb.mi/gdb701
/testsuite/gdb.mi/gdb792
/testsuite/gdb.mi/mi-basics
/testsuite/gdb.mi/mi-break
/testsuite/gdb.mi/mi-cli
/testsuite/gdb.mi/mi-console
/testsuite/gdb.mi/mi-disassemble
/testsuite/gdb.mi/mi-eval
/testsuite/gdb.mi/mi-file
/testsuite/gdb.mi/mi-read-memory
/testsuite/gdb.mi/mi-regs
/testsuite/gdb.mi/mi-return
/testsuite/gdb.mi/mi-simplerun
/testsuite/gdb.mi/mi-stack
/testsuite/gdb.mi/mi-stepi
/testsuite/gdb.mi/mi-var-block
/testsuite/gdb.mi/mi-var-child
/testsuite/gdb.mi/mi-var-cmd
/testsuite/gdb.mi/mi-var-cp
/testsuite/gdb.mi/mi-var-display
/testsuite/gdb.mi/mi-var-invalidate
/testsuite/gdb.mi/mi-var-invalidate_bis
/testsuite/gdb.mi/mi-watch
/testsuite/gdb.mi/mi2-basics
/testsuite/gdb.mi/mi2-break
/testsuite/gdb.mi/mi2-cli
/testsuite/gdb.mi/mi2-disassemble
/testsuite/gdb.mi/mi2-eval
/testsuite/gdb.mi/mi2-file
/testsuite/gdb.mi/mi2-regs
/testsuite/gdb.mi/mi2-return
/testsuite/gdb.mi/mi2-simplerun
/testsuite/gdb.mi/mi2-stepi
/testsuite/gdb.mi/mi2-var-block
/testsuite/gdb.mi/mi2-var-child
/testsuite/gdb.mi/mi2-var-cmd
/testsuite/gdb.mi/mi2-var-display
/testsuite/gdb.mi/mi2-watch
/testsuite/gdb.mi/until
/testsuite/gdb.modula2/unbounded1
/testsuite/gdb.python/py-frame
/testsuite/gdb.stabs/exclfwd
/testsuite/gdb.threads/tls-main
/testsuite/gdb.threads/tls-nodebug
/testsuite/gdb.threads/tls-shared.so
/testsuite/gdb.trace/backtrace
/testsuite/gdb.trace/deltrace
/testsuite/gdb.trace/infotrace
/testsuite/gdb.trace/packetlen
/testsuite/gdb.trace/passc-dyn
/testsuite/gdb.trace/passcount
/testsuite/gdb.trace/report
/testsuite/gdb.trace/save-trace
/testsuite/gdb.trace/tfile
/testsuite/gdb.trace/tfind
/testsuite/gdb.trace/tracecmd
/testsuite/gdb.trace/tsv
/testsuite/gdb.trace/while-dyn
/testsuite/gdb.trace/while-stepping
/testsuite/tracecommandsscript

View File

@@ -192,6 +192,13 @@ convert_from_func_ptr_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr,
return addr;
}
CORE_ADDR
convert_from_addr_func_ptr_identity (struct gdbarch *gdbarch, CORE_ADDR addr,
struct target_ops *targ)
{
return addr;
}
int
no_op_reg_to_regnum (struct gdbarch *gdbarch, int reg)
{

View File

@@ -90,6 +90,7 @@ extern int core_addr_greaterthan (CORE_ADDR lhs, CORE_ADDR rhs);
extern CORE_ADDR core_addr_identity (struct gdbarch *gdbarch, CORE_ADDR addr);
extern gdbarch_convert_from_func_ptr_addr_ftype convert_from_func_ptr_addr_identity;
extern gdbarch_convert_from_addr_func_ptr_ftype convert_from_addr_func_ptr_identity;
/* No-op conversion of reg to regnum. */

View File

@@ -37,6 +37,8 @@
#include "elf/bfin.h"
#include "osabi.h"
#include "infcall.h"
#include "solib.h"
#include "solib-fdpic.h"
#include "xml-syscall.h"
#include "bfin-tdep.h"
@@ -491,6 +493,58 @@ bfin_register_type (struct gdbarch *gdbarch, int regnum)
return builtin_type (gdbarch)->builtin_int32;
}
static CORE_ADDR
find_func_descr (struct gdbarch *gdbarch, CORE_ADDR entry_point)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR descr;
char valbuf[4];
descr = fdpic_find_canonical_descriptor (entry_point);
if (descr != 0)
return descr;
/* Construct a non-canonical descriptor from space allocated on
the stack. */
descr = value_as_long (value_allocate_space_in_inferior (8));
store_unsigned_integer (valbuf, 4, byte_order, entry_point);
write_memory (descr, valbuf, 4);
store_unsigned_integer (valbuf, 4, byte_order,
fdpic_find_global_pointer (entry_point));
write_memory (descr + 4, valbuf, 4);
return descr;
}
static CORE_ADDR
bfin_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
struct target_ops *targ)
{
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR entry_point;
CORE_ADDR got_address;
entry_point = get_target_memory_unsigned (targ, addr, 4, byte_order);
got_address = get_target_memory_unsigned (targ, addr + 4, 4, byte_order);
if (got_address == fdpic_find_global_pointer (entry_point))
return entry_point;
else
return addr;
}
static CORE_ADDR
bfin_convert_from_addr_func_ptr (struct gdbarch *gdbarch, CORE_ADDR addr,
struct target_ops *targ)
{
CORE_ADDR descr;
descr = find_func_descr (gdbarch, addr);
return descr;
}
static CORE_ADDR
bfin_push_dummy_call (struct gdbarch *gdbarch,
struct value *function,
@@ -552,6 +606,14 @@ bfin_push_dummy_call (struct gdbarch *gdbarch,
regcache_cooked_write_unsigned (regcache, BFIN_RETS_REGNUM, bp_addr);
if (abi == BFIN_ABI_FDPIC)
{
/* Set the GOT register for the FDPIC ABI. */
regcache_cooked_write_unsigned
(regcache, BFIN_P3_REGNUM,
fdpic_find_global_pointer (func_addr));
}
/* Finally, update the stack pointer. */
regcache_cooked_write_unsigned (regcache, BFIN_SP_REGNUM, sp);
@@ -779,9 +841,19 @@ static struct gdbarch *
bfin_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
{
struct gdbarch *gdbarch;
int elf_flags;
enum bfin_abi abi;
abi = BFIN_ABI_FLAT;
/* Extract the ELF flags, if available. */
if (info.abfd && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour)
elf_flags = elf_elfheader (info.abfd)->e_flags;
else
elf_flags = 0;
if (elf_flags & EF_BFIN_FDPIC)
abi = BFIN_ABI_FDPIC;
else
abi = BFIN_ABI_FLAT;
/* If there is already a candidate, use it. */
@@ -824,6 +896,8 @@ bfin_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_frame_args_skip (gdbarch, 8);
set_gdbarch_frame_align (gdbarch, bfin_frame_align);
set_gdbarch_so_ops (gdbarch, &fdpic_so_ops);
/* Hook in ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
@@ -833,6 +907,17 @@ bfin_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
frame_unwind_append_unwinder (gdbarch, &bfin_frame_unwind);
if (bfin_abi (gdbarch) == BFIN_ABI_FDPIC)
{
set_gdbarch_convert_from_func_ptr_addr (gdbarch,
bfin_convert_from_func_ptr_addr);
set_gdbarch_convert_from_addr_func_ptr (gdbarch,
bfin_convert_from_addr_func_ptr);
}
if (bfin_abi (gdbarch) == BFIN_ABI_FDPIC)
set_gdbarch_use_get_offsets (gdbarch, 0);
return gdbarch;
}

View File

@@ -92,7 +92,8 @@ enum gdb_regnum {
/* The ABIs for Blackfin. */
enum bfin_abi
{
BFIN_ABI_FLAT
BFIN_ABI_FLAT,
BFIN_ABI_FDPIC
};
/* Target-dependent structure in gdbarch. */

View File

@@ -210,7 +210,8 @@ avr-*-*)
bfin-*-*linux*)
# Target: Blackfin Linux
gdb_target_obs="bfin-tdep.o bfin-linux-tdep.o linux-tdep.o"
gdb_target_obs="bfin-tdep.o bfin-linux-tdep.o linux-tdep.o
solib.o solib-bfin.o"
;;
bfin-*-*)
# Target: Blackfin processor

View File

@@ -36,6 +36,7 @@
#include "osabi.h"
#include "infcall.h"
#include "solib.h"
#include "solib-fdpic.h"
#include "frv-tdep.h"
#include "objfiles.h"
#include "gdbarch.h"
@@ -97,37 +98,6 @@ frv_abi (struct gdbarch *gdbarch)
return tdep->frv_abi;
}
/* Fetch the interpreter and executable loadmap addresses (for shared
library support) for the FDPIC ABI. Return 0 if successful, -1 if
not. (E.g, -1 will be returned if the ABI isn't the FDPIC ABI.) */
int
frv_fdpic_loadmap_addresses (struct gdbarch *gdbarch, CORE_ADDR *interp_addr,
CORE_ADDR *exec_addr)
{
if (frv_abi (gdbarch) != FRV_ABI_FDPIC)
return -1;
else
{
struct regcache *regcache = get_current_regcache ();
if (interp_addr != NULL)
{
ULONGEST val;
regcache_cooked_read_unsigned (regcache,
fdpic_loadmap_interp_regnum, &val);
*interp_addr = val;
}
if (exec_addr != NULL)
{
ULONGEST val;
regcache_cooked_read_unsigned (regcache,
fdpic_loadmap_exec_regnum, &val);
*exec_addr = val;
}
return 0;
}
}
/* Allocate a new variant structure, and set up default values for all
the fields. */
static frv_gdbarch_tdep *
@@ -1146,7 +1116,7 @@ find_func_descr (struct gdbarch *gdbarch, CORE_ADDR entry_point)
|| entry_point != start_addr)
return entry_point;
descr = frv_fdpic_find_canonical_descriptor (entry_point);
descr = fdpic_find_canonical_descriptor (entry_point);
if (descr != 0)
return descr;
@@ -1158,7 +1128,7 @@ find_func_descr (struct gdbarch *gdbarch, CORE_ADDR entry_point)
store_unsigned_integer (valbuf, 4, byte_order, entry_point);
write_memory (descr, valbuf, 4);
store_unsigned_integer (valbuf, 4, byte_order,
frv_fdpic_find_global_pointer (entry_point));
fdpic_find_global_pointer (entry_point));
write_memory (descr + 4, valbuf, 4);
return descr;
}
@@ -1174,7 +1144,7 @@ frv_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
entry_point = get_target_memory_unsigned (targ, addr, 4, byte_order);
got_address = get_target_memory_unsigned (targ, addr + 4, 4, byte_order);
if (got_address == frv_fdpic_find_global_pointer (entry_point))
if (got_address == fdpic_find_global_pointer (entry_point))
return entry_point;
else
return addr;
@@ -1299,7 +1269,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* Set the GOT register for the FDPIC ABI. */
regcache_cooked_write_unsigned
(regcache, first_gpr_regnum + 15,
frv_fdpic_find_global_pointer (func_addr));
fdpic_find_global_pointer (func_addr));
}
/* Finally, update the SP register. */
@@ -1548,7 +1518,7 @@ frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_gdbarch_convert_from_func_ptr_addr (gdbarch,
frv_convert_from_func_ptr_addr);
set_gdbarch_so_ops (gdbarch, &frv_so_ops);
set_gdbarch_so_ops (gdbarch, &fdpic_so_ops);
/* Hook in ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
@@ -1558,7 +1528,7 @@ frv_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
/* Enable TLS support. */
set_gdbarch_fetch_tls_load_module_address (gdbarch,
frv_fetch_objfile_link_map);
fdpic_fetch_objfile_link_map);
return gdbarch;
}

View File

@@ -95,30 +95,9 @@ enum {
frv_num_pseudo_regs = last_pseudo_regnum - first_pseudo_regnum + 1,
};
struct gdbarch;
/* Return the FR-V ABI associated with GDBARCH. */
enum frv_abi frv_abi (struct gdbarch *gdbarch);
/* Fetch the interpreter and executable loadmap addresses (for shared
library support) for the FDPIC ABI. Return 0 if successful, -1 if
not. (E.g, -1 will be returned if the ABI isn't the FDPIC ABI.) */
int frv_fdpic_loadmap_addresses (struct gdbarch *gdbarch,
CORE_ADDR *interp_addr, CORE_ADDR *exec_addr);
/* Given a function entry point, find and return the GOT address for the
containing load module. */
CORE_ADDR frv_fdpic_find_global_pointer (CORE_ADDR addr);
/* Given a function entry point, find and return the canonical descriptor
for that function, if one exists. If no canonical descriptor could
be found, return 0. */
CORE_ADDR frv_fdpic_find_canonical_descriptor (CORE_ADDR entry_point);
/* Given an objfile, return the address of its link map. This value is
needed for TLS support. */
CORE_ADDR frv_fetch_objfile_link_map (struct objfile *objfile);
struct target_so_ops;
extern const struct target_so_ops frv_so_ops;
#endif /* FRV_TDEP_H */

View File

@@ -1120,6 +1120,14 @@ Method(
invalid=False,
)
Method(
type="CORE_ADDR",
name="convert_from_addr_func_ptr",
params=[("CORE_ADDR", "addr"), ("struct target_ops *", "targ")],
predefault="convert_from_addr_func_ptr_identity",
invalid=False,
)
Method(
comment="""
On some machines there are bits in addresses which are not really
@@ -2311,6 +2319,16 @@ True if inferiors share an address space (e.g., uClinux).
invalid=False,
)
Value(
comment="""
Query the remote side for the text, data and bss offsets.
""",
type="int",
name="use_get_offsets",
predefault="1",
invalid=False,
)
Method(
comment="""
True if a fast tracepoint can be set at an address.

View File

@@ -601,6 +601,10 @@ typedef CORE_ADDR (gdbarch_convert_from_func_ptr_addr_ftype) (struct gdbarch *gd
extern CORE_ADDR gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ);
extern void set_gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch, gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr);
typedef CORE_ADDR (gdbarch_convert_from_addr_func_ptr_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ);
extern CORE_ADDR gdbarch_convert_from_addr_func_ptr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ);
extern void set_gdbarch_convert_from_addr_func_ptr (struct gdbarch *gdbarch, gdbarch_convert_from_addr_func_ptr_ftype *convert_from_addr_func_ptr);
/* On some machines there are bits in addresses which are not really
part of the address, but are used by the kernel, the hardware, etc.
for special purposes. gdbarch_addr_bits_remove takes out any such bits so
@@ -1423,6 +1427,11 @@ typedef int (gdbarch_has_shared_address_space_ftype) (struct gdbarch *gdbarch);
extern int gdbarch_has_shared_address_space (struct gdbarch *gdbarch);
extern void set_gdbarch_has_shared_address_space (struct gdbarch *gdbarch, gdbarch_has_shared_address_space_ftype *has_shared_address_space);
/* Query the remote side for the text, data and bss offsets. */
extern int gdbarch_use_get_offsets (struct gdbarch *gdbarch);
extern void set_gdbarch_use_get_offsets (struct gdbarch *gdbarch, int use_get_offsets);
/* True if a fast tracepoint can be set at an address. */
typedef int (gdbarch_fast_tracepoint_valid_at_ftype) (struct gdbarch *gdbarch, CORE_ADDR addr, std::string *msg);

View File

@@ -141,6 +141,7 @@ struct gdbarch
gdbarch_stabs_argument_has_addr_ftype *stabs_argument_has_addr = default_stabs_argument_has_addr;
int frame_red_zone_size = 0;
gdbarch_convert_from_func_ptr_addr_ftype *convert_from_func_ptr_addr = convert_from_func_ptr_addr_identity;
gdbarch_convert_from_addr_func_ptr_ftype *convert_from_addr_func_ptr = convert_from_addr_func_ptr_identity;
gdbarch_addr_bits_remove_ftype *addr_bits_remove = core_addr_identity;
int significant_addr_bit = 0;
gdbarch_memtag_to_string_ftype *memtag_to_string = default_memtag_to_string;
@@ -225,6 +226,7 @@ struct gdbarch
int has_global_solist = 0;
int has_global_breakpoints = 0;
gdbarch_has_shared_address_space_ftype *has_shared_address_space = default_has_shared_address_space;
int use_get_offsets = 1;
gdbarch_fast_tracepoint_valid_at_ftype *fast_tracepoint_valid_at = default_fast_tracepoint_valid_at;
gdbarch_guess_tracepoint_registers_ftype *guess_tracepoint_registers = default_guess_tracepoint_registers;
gdbarch_auto_charset_ftype *auto_charset = default_auto_charset;
@@ -397,6 +399,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of stabs_argument_has_addr, invalid_p == 0 */
/* Skip verify of frame_red_zone_size, invalid_p == 0 */
/* Skip verify of convert_from_func_ptr_addr, invalid_p == 0 */
/* Skip verify of convert_from_addr_func_ptr, invalid_p == 0 */
/* Skip verify of addr_bits_remove, invalid_p == 0 */
/* Skip verify of significant_addr_bit, invalid_p == 0 */
/* Skip verify of memtag_to_string, invalid_p == 0 */
@@ -483,6 +486,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of has_global_solist, invalid_p == 0 */
/* Skip verify of has_global_breakpoints, invalid_p == 0 */
/* Skip verify of has_shared_address_space, invalid_p == 0 */
/* Skip verify of use_get_offsets, invalid_p == 0 */
/* Skip verify of fast_tracepoint_valid_at, invalid_p == 0 */
/* Skip verify of guess_tracepoint_registers, invalid_p == 0 */
/* Skip verify of auto_charset, invalid_p == 0 */
@@ -876,6 +880,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
gdb_printf (file,
"gdbarch_dump: convert_from_func_ptr_addr = <%s>\n",
host_address_to_string (gdbarch->convert_from_func_ptr_addr));
gdb_printf (file,
"gdbarch_dump: convert_from_addr_func_ptr = <%s>\n",
host_address_to_string (gdbarch->convert_from_addr_func_ptr));
gdb_printf (file,
"gdbarch_dump: addr_bits_remove = <%s>\n",
host_address_to_string (gdbarch->addr_bits_remove));
@@ -1251,6 +1258,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
gdb_printf (file,
"gdbarch_dump: has_shared_address_space = <%s>\n",
host_address_to_string (gdbarch->has_shared_address_space));
gdb_printf (file,
"gdbarch_dump: use_get_offsets = %s\n",
plongest (gdbarch->use_get_offsets));
gdb_printf (file,
"gdbarch_dump: fast_tracepoint_valid_at = <%s>\n",
host_address_to_string (gdbarch->fast_tracepoint_valid_at));
@@ -3061,6 +3071,23 @@ set_gdbarch_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
gdbarch->convert_from_func_ptr_addr = convert_from_func_ptr_addr;
}
CORE_ADDR
gdbarch_convert_from_addr_func_ptr (struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ)
{
gdb_assert (gdbarch != NULL);
gdb_assert (gdbarch->convert_from_addr_func_ptr != NULL);
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_convert_from_addr_func_ptr called\n");
return gdbarch->convert_from_addr_func_ptr (gdbarch, addr, targ);
}
void
set_gdbarch_convert_from_addr_func_ptr (struct gdbarch *gdbarch,
gdbarch_convert_from_addr_func_ptr_ftype convert_from_addr_func_ptr)
{
gdbarch->convert_from_addr_func_ptr = convert_from_addr_func_ptr;
}
CORE_ADDR
gdbarch_addr_bits_remove (struct gdbarch *gdbarch, CORE_ADDR addr)
{
@@ -4779,6 +4806,23 @@ set_gdbarch_has_shared_address_space (struct gdbarch *gdbarch,
gdbarch->has_shared_address_space = has_shared_address_space;
}
int
gdbarch_use_get_offsets (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
/* Skip verify of use_get_offsets, invalid_p == 0 */
if (gdbarch_debug >= 2)
gdb_printf (gdb_stdlog, "gdbarch_use_get_offsets called\n");
return gdbarch->use_get_offsets;
}
void
set_gdbarch_use_get_offsets (struct gdbarch *gdbarch,
int use_get_offsets)
{
gdbarch->use_get_offsets = use_get_offsets;
}
int
gdbarch_fast_tracepoint_valid_at (struct gdbarch *gdbarch, CORE_ADDR addr, std::string *msg)
{

View File

@@ -5006,6 +5006,10 @@ remote_target::start_remote_1 (int from_tty, int extended_p)
return false;
}
/* Get text, data & bss offsets. */
if (gdbarch_use_get_offsets (target_gdbarch))
get_offsets ();
/* Report all signals during attach/startup. */
pass_signals ({});

35
gdb/solib-bfin.c Normal file
View File

@@ -0,0 +1,35 @@
/* Handle Blackfin (FDPIC) shared libraries for GDB, the GNU Debugger.
Copyright (C) 2004, 2006, 2007, 2008, 2009, 2010
Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "solib-fdpic.h"
#include "bfin-tdep.h"
#include "elf/bfin.h"
#define arch_abi bfin_abi
#define ARCH_ABI_FDPIC BFIN_ABI_FDPIC
#define R_ARCH_FUNCDESC R_BFIN_FUNCDESC
#define FDPIC_INTERP_REGNUM 0 /*BFIN_FDPIC_INTERP_REGNUM*/
#define FDPIC_EXEC_REGNUM 1 /*BFIN_FDPIC_EXEC_REGNUM*/
#define LINKER_SYM(sym) "_"sym
/* Provide a prototype to silence -Wmissing-prototypes and for init.c. */
extern initialize_file_ftype
_initialize_fdpic_solib;
#include "solib-fdpic.c"

1182
gdb/solib-fdpic.c Normal file

File diff suppressed because it is too large Load Diff

72
gdb/solib-fdpic.h Normal file
View File

@@ -0,0 +1,72 @@
/* Handle FDPIC shared libraries for GDB, the GNU Debugger.
Copyright (C) 2004, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef SOLIB_FDPIC_H
#define SOLIB_FDPIC_H
#include "defs.h"
#include "inferior.h"
#include "gdbcore.h"
#include "solib.h"
#include "solist.h"
#include "objfiles.h"
#include "symtab.h"
#include "language.h"
#include "command.h"
#include "gdbcmd.h"
#include "regcache.h"
/* Targets implementing FDPIC shared libraries should define:
arch_abi (required)
ARCH_ABI_FDPIC (required)
R_ARCH_FUNCDESC (required)
FDPIC_EXEC_REGNUM (required)
FDPIC_INTERP_REGNUM (required)
LINKER_SYM (optional)
*/
/* Given a function entry point, find and return the GOT address for the
containing load module. */
CORE_ADDR fdpic_find_global_pointer (CORE_ADDR addr);
/* Given a function entry point, find and return the canonical descriptor
for that function, if one exists. If no canonical descriptor could
be found, return 0. */
CORE_ADDR fdpic_find_canonical_descriptor (CORE_ADDR entry_point);
/* Given an objfile, return the address of its link map. This value is
needed for TLS support. */
CORE_ADDR fdpic_fetch_objfile_link_map (struct objfile *objfile);
/* Fetch the interpreter and executable loadmap addresses (for shared
library support) for the FDPIC ABI. Return 0 if successful, -1 if
not. (E.g, -1 will be returned if the ABI isn't the FDPIC ABI.) */
int fdpic_loadmap_addresses (struct gdbarch *gdbarch, CORE_ADDR *interp_addr,
CORE_ADDR *exec_addr);
struct target_so_ops;
extern const struct target_so_ops fdpic_so_ops;
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -395,7 +395,8 @@ place_section (bfd *abfd, asection *sect, section_offsets &offsets,
}
while (!done);
offsets[gdb_bfd_section_index (abfd, sect)] = start_addr;
offsets[gdb_bfd_section_index (abfd, sect)] =
start_addr - bfd_section_vma (sect);
lowest = start_addr + bfd_section_size (sect);
}

View File

@@ -43,8 +43,18 @@ switch -glob -- [istarget] {
"aarch64*-*-*" {
set asm-arch aarch64
}
"bfin-*-*" {
"bfin-*-elf" {
set asm-arch bfin
set debug-flags "-g"
}
"bfin-*-uclinux" {
set asm-arch bfin
set debug-flags "-g"
if ![target_info exists use_binfmt_flat] {
verbose "Skipping asm-source.exp for bfin-uclinux fdpic."
continue;
}
append link-flags " -elf2flt"
}
"frv-*-*" {
set asm-arch frv

View File

@@ -17,6 +17,13 @@
# This is a test for the gdb command "dump".
# Blackfin does not have MMU. The load address might change between
# different invocations of application. So it is not guaranteed that
# dump file from one invocation can be restored in another invocation.
if { [istarget "bfin-*-uclinux"] || [istarget "bfin-*-linux-uclibc"] } then {
return 0
}
standard_testfile
set options {debug}

View File

@@ -4536,6 +4536,16 @@ proc current_target_name { } {
return $answer
}
proc gdb_get_exec_name { binfile } {
# FLAT toolchains have to load the .flt file to the board
if { [target_info exists use_binfmt_flat]
&& [file exists "${binfile}.flt"] } {
return "${binfile}.flt"
} else {
return ${binfile}
}
}
set gdb_wrapper_initialized 0
set gdb_wrapper_target ""
set gdb_wrapper_file ""
@@ -5023,6 +5033,16 @@ proc gdb_compile {source dest type options} {
clone_output "gdb compile failed, $result"
}
}
# FLAT toolchains output a bFLT file with the default name and create
# a secondary ELF file with a .gdb suffix. GDB needs the ELF file in
# order to do debugging, so flip-flop things.
if { [target_info exists use_binfmt_flat]
&& [file exists "${dest}.gdb"] } {
file rename -force "${dest}" "${dest}.flt"
file rename -force "${dest}.gdb" "${dest}"
}
return $result
}

View File

@@ -1527,12 +1527,18 @@ struct value *
value_coerce_function (struct value *arg1)
{
struct value *retval;
CORE_ADDR addr;
if (VALUE_LVAL (arg1) != lval_memory)
error (_("Attempt to take address of value not located in memory."));
addr = value_address (arg1);
addr = gdbarch_convert_from_addr_func_ptr (target_gdbarch,
addr,
&current_target);
retval = value_from_pointer (lookup_pointer_type (value_type (arg1)),
value_address (arg1));
addr);
return retval;
}

24
include/elf/fdpic.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef _ELF_FDPIC_H
#define _ELF_FDPIC_H
struct elf32_fdpic_loadseg
{
/* Core address to which the segment is mapped. */
Elf32_Addr addr;
/* VMA recorded in the program header. */
Elf32_Addr p_vaddr;
/* Size of this segment in memory. */
Elf32_Word p_memsz;
};
struct elf32_fdpic_loadmap
{
/* Protocol version number, must be zero. */
Elf32_Half version;
/* Number of segments in this map. */
Elf32_Half nsegs;
/* The actual memory map. */
struct elf32_fdpic_loadseg segs[/*nsegs*/];
};
#endif /* _ELF_FDPIC_H */