Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Iain Sandoe <developer@sandoe-acoustics.co.uk>
To: Doug Evans <dje@google.com>, Tristan Gingold <gingold@adacore.com>
Cc: gdb-patches@sourceware.org,
	binutils Development <binutils@sourceware.org>
Subject: Re: [RFC] Add support for .debug_gdb_scripts to mach-o.
Date: Sun, 01 Jan 2012 19:07:00 -0000	[thread overview]
Message-ID: <9DF778D7-0B95-45CF-BA18-5890788BFE3C@sandoe-acoustics.co.uk> (raw)
In-Reply-To: <F3A1D139-2450-423C-B4AE-480BBD92E154@sandoe-acoustics.co.uk>


On 31 Dec 2011, at 15:12, Iain Sandoe wrote:

>> There is a testcase for .debug_gdb_scripts in
>> gdb/testsuite/gdb.python/py-section-script.exp
>> but I'm not sure it'll work as is on mach-o.
>
> no, it won't - we don't yet support .push/pop section in mach-o gas.

Alas, although that wasn't too hard to implement, we're still some way  
away from being able to build GCC with GAS, so we still need to work  
with the native system tools.

> (will try to fit in a look at this, at some stage

With http://sourceware.org/ml/gdb-patches/2011-12/msg00890.html  
applied, the following patch below gives:

Native configuration is i686-apple-darwin9

                 === gdb tests ===
...
Running ../../../src-git/gdb/testsuite/gdb.python/py-section- 
script.exp ...

                 === gdb Summary ===

# of expected passes            6

====

NOTES:

1. We cannot put a 'debug' section attribute on the debug_gdb_scripts  
section, because then dsymutil will automatically strip it from the  
exe - but (presumably because it's unrecognized) it doesn't put it  
into the dSYM, even when one specifies 'no_dead_strip'
.. :-( ...

2. The section switch has to be done specifically until we can build  
with gas.

3. maybe the DEFINE_GDB_SCRIPT macro should be guarded something like...
#if defined (__ELF__)
...
#elif defined (__MACH__)
...
(but I'm not sure how many targets can use it as stands...)

cheers
Iain

====


diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index cc68d89..1404bb9 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -195,6 +195,9 @@ static const mach_o_section_name_xlat  
dwarf_section_names_xlat[] =
      {	".debug_macro",			"__debug_macro",
  	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
  	BFD_MACH_O_S_ATTR_DEBUG,	0},
+    {	".debug_gdb_scripts",		"__debug_gdb_scr",
+	SEC_DEBUGGING,			BFD_MACH_O_S_REGULAR,
+	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, 0},
      { NULL, NULL, 0, 0, 0, 0}
    };


diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
index 804d42b..4953a91 100644
--- a/gas/config/obj-macho.c
+++ b/gas/config/obj-macho.c
@@ -559,7 +561,8 @@ static const char * const debug_sections[] =
    /*  9 */ ".debug_pubtypes",
    /* 10 */ ".debug_str",
    /* 11 */ ".debug_ranges",
-  /* 12 */ ".debug_macro"
+  /* 12 */ ".debug_macro",
+  /* 13 */ ".debug_gdb_scripts",
  };

  /* ??? Maybe these should be conditional on gdwarf-*.
@@ -1064,6 +1067,7 @@ const pseudo_typeS mach_o_pseudo_table[] =
    { "debug_str", obj_mach_o_debug_section, 10}, /* extension.  */
    { "debug_ranges", obj_mach_o_debug_section, 11}, /* extension.  */
    { "debug_macro", obj_mach_o_debug_section, 12}, /* extension.  */
+  { "debug_gdb_scripts", obj_mach_o_debug_section, 13}, /*  
extension.  */

    { "lazy_symbol_pointer", obj_mach_o_opt_tgt_section, 1},
    { "lazy_symbol_pointer2", obj_mach_o_opt_tgt_section, 2}, /*  
extension.  */

diff --git a/gdb/testsuite/gdb.python/py-section-script.c b/gdb/ 
testsuite/gdb.python/py-section-script.c
index 1ead7dd..6d48071 100644
--- a/gdb/testsuite/gdb.python/py-section-script.c
+++ b/gdb/testsuite/gdb.python/py-section-script.c
@@ -18,6 +18,7 @@
  /* Put the path to the pretty-printer script in .debug_gdb_scripts so
     gdb will automagically loaded it.  */

+#ifndef __MACH__
  #define DEFINE_GDB_SCRIPT(script_name) \
    asm("\
  .pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n\
@@ -25,6 +26,14 @@
  .asciz \"" script_name "\"\n\
  .popsection \n\
  ");
+#else
+#define DEFINE_GDB_SCRIPT(script_name) \
+  asm(".section __DWARF,__debug_gdb_scr,regular,no_dead_strip\n\
+	.byte 1\n\
+	.asciz \"" script_name "\"\n\
+	.text\n\
+      ");
+#endif

  DEFINE_GDB_SCRIPT ("py-section-script.py")


diff --git a/gdb/testsuite/gdb.python/py-section-script.exp b/gdb/ 
testsuite/gdb.python/py-section-script.exp
index 31fdcf8..1cde576 100644
--- a/gdb/testsuite/gdb.python/py-section-script.exp
+++ b/gdb/testsuite/gdb.python/py-section-script.exp
@@ -24,7 +24,8 @@ if {![istarget *-*-linux*]
      && ![istarget *-*-openbsd*]
      && ![istarget arm*-*-eabi*]
      && ![istarget arm*-*-symbianelf*]
-    && ![istarget powerpc-*-eabi*]} {
+    && ![istarget powerpc-*-eabi*]
+    && ![istarget i?86-*-darwin*]} {
      verbose "Skipping py-section-script.exp because of lack of  
support."
      return
  }



      reply	other threads:[~2012-01-01 19:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-28  0:35 Doug Evans
2011-12-31 20:11 ` Iain Sandoe
2012-01-01 19:07   ` Iain Sandoe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9DF778D7-0B95-45CF-BA18-5890788BFE3C@sandoe-acoustics.co.uk \
    --to=developer@sandoe-acoustics.co.uk \
    --cc=binutils@sourceware.org \
    --cc=dje@google.com \
    --cc=gdb-patches@sourceware.org \
    --cc=gingold@adacore.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox