[RFC][PATCH] Move common handlers to sol2_init_abi

Rainer Orth ro@CeBiTec.Uni-Bielefeld.DE
Tue Jun 23 13:15:57 GMT 2020


There's some overlap and duplication between 32 and 64-bit Solaris/SPARC
and x86 tdep files, in particular

        sol2_core_pid_to_str
	*_sol2_sigtramp_p
        sol2_skip_solib_resolver
        *_sol2_static_transform_name (forgotten on amd64)
        set_gdbarch_sofun_address_maybe_missing (likewise)

This patch avoids this by centralizing common code in sol2-tdep.c.
While sparc_sol2_pc_in_sigtramp and sparc_sol2_static_transform_name
were declared in the shared sparc-tdep.h, they were only used in Solaris
files.

However, I just discovered that there are two targets that would break
with this patch: both sparc-*-linux* and sparc64-*-linux* include
sparc-sol2-tdep.o and sparc64-sol2-tdep.o in configure.tgt.  With the
new call to sol2_init_abi which only lives in sol2-tdep.o, gdb would
fail to link.  I have no idea what business they have with
Solaris-specific files: I suspect that's to allow debugging of
Solaris/SPARC binaries (i.e. GDB_OSABI_SOLARIS).  What should I do about
this?  Maybe I also could include sol2-tdep.o on Linux/SPARC, but is
this TRT?  AFAICS those files received only mechanical changes over the
last two years (haven't looked further), and I have no way of testing
changes.

Tested on amd64-pc-solaris2.11, i386-pc-solaris2.11,
sparcv9-sun-solaris2.11, and sparc-sun-solaris2.11.

While those patches only/mostly affect Solaris-specific code, I have
some questions:

* Two settings above (static_transform_name,
  sofun_address_maybe_missing) only apply to quirks of stabs.

  The first is completely Solaris-specific (or rather specific to the
  Studio compilers) and I didn't do any real testing here.  Studio cc
  has deprecated stabs support in the 12.4 release back in 2015, gcc has
  defaulted to DWARF-2 on Solaris 7+ since 2004, so maybe the whole
  static_transform_name code can go?

  The second is also called in i386-linux-tdep.c and rs6000-tdep.c and I
  don't know enough about this to say what to do here.

* Beyond that, maybe it's time to think about deprecating Stabs support
  in general.  There has been some discussion on the GCC side

  https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01297.html

  but nothing happened yet.

* When running gdb_ari.sh on the changed files, I got some warnings:

./sol2-tdep.c:156: warning: gdbarch: Call to set_gdbarch_sofun_address_maybe_missing
./sol2-tdep.c:160: warning: gdbarch: Call to set_gdbarch_static_transform_name
./sol2-tdep.c:163: warning: gdbarch: Call to set_gdbarch_skip_solib_resolver
./sol2-tdep.c:166: warning: gdbarch: Call to set_gdbarch_core_pid_to_str
./sparc64-sol2-tdep.c:216: warning: gdbarch: Call to set_gdbarch_skip_trampoline_code
./sparc64-sol2-tdep.c:225: warning: gdbarch: Call to set_gdbarch_software_single_step

  However, all of those calls occur all over the code.  What's worse,
  ARI doesn't give any indication what's the correct way instead.

Thanks.
	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2018-06-27  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* amd64-sol2-tdep.c (amd64_sol2_sigtramp_p): Remove.
	(amd64_sol2_init_abi): Use sol2_sigtramp_p.
	Call sol2_init_abi.
 	Remove calls to set_gdbarch_skip_solib_resolver,
	set_gdbarch_core_pid_to_str.
	* i386-sol2-tdep.c (i386_sol2_sigtramp_p): Remove.
	(i386_sol2_static_transform_name): Remove.
	(i386_sol2_init_abi): Call sol2_init_abi.
	Remove calls to set_gdbarch_sofun_address_maybe_missing,
	set_gdbarch_static_transform_name,
	set_gdbarch_skip_solib_resolver, set_gdbarch_core_pid_to_str.
	Use sol2_sigtramp_p.
	* sol2-tdep.c (sol2_pc_in_sigtramp): New function.
	(sol2_sigtramp_p): New function.
	(sol2_static_transform_name): New function.
	(sol2_skip_solib_resolver, sol2_core_pid_to_str): Make static.
	(sol2_init_abi): New function.
	* sol2-tdep.h (sol2_sigtramp_p, sol2_init_abi): Declare.
	(sol2_skip_solib_resolver, sol2_core_pid_to_str): Remove.
	* sparc-sol2-tdep.c (sparc_sol2_pc_in_sigtramp): Remove.
	(sparc32_sol2_sigtramp_frame_sniffer): Just call sol2_sigtramp_p.
	(sparc_sol2_static_transform_name): Remove.
	(sparc32_sol2_init_abi): Call sol2_init_abi.
	Remove calls to set_gdbarch_sofun_address_maybe_missing,
	set_gdbarch_static_transform_name,
	set_gdbarch_skip_solib_resolver,
	set_gdbarch_core_pid_to_str.
	* sparc-tdep.h (sparc_sol2_pc_in_sigtramp)
	(sparc_sol2_static_transform_name): Remove
	* sparc64-sol2-tdep.c (sparc64_sol2_sigtramp_frame_sniffer): Just
	call sol2_sigtramp_p.
	(sparc64_sol2_init_abi): Call sol2_init_abi.
	Remove calls to set_gdbarch_sofun_address_maybe_missing,
	set_gdbarch_static_transform_name,
	set_gdbarch_skip_solib_resolver, set_gdbarch_core_pid_to_str.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: sol2-common-init_abi.patch
Type: text/x-patch
Size: 17576 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/gdb-patches/attachments/20200623/1b358686/attachment.bin>


More information about the Gdb-patches mailing list