* [RFC] Add support for .debug_gdb_scripts to mach-o.
@ 2011-12-28 0:35 Doug Evans
2011-12-31 20:11 ` Iain Sandoe
0 siblings, 1 reply; 3+ messages in thread
From: Doug Evans @ 2011-12-28 0:35 UTC (permalink / raw)
To: gdb-patches, binutils
Hi.
I have no means of testing this.
And it's not clear that adding .debug_gdb_scripts to dwarf_section_names_xlat
is reasonable.
Can anyone using mach-o test this, or suggest a better fix?
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.
TIA
2011-12-27 Doug Evans <dje@google.com>
* mach-o.c (dwarf_section_names_xlat): Add .debug_gdb_scripts.
Index: mach-o.c
===================================================================
RCS file: /cvs/src/src/bfd/mach-o.c,v
retrieving revision 1.81
diff -u -p -r1.81 mach-o.c
--- mach-o.c 19 Dec 2011 15:42:36 -0000 1.81
+++ mach-o.c 28 Dec 2011 00:15:14 -0000
@@ -195,6 +195,9 @@ static const mach_o_section_name_xlat dw
{ ".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_DEBUG, 0},
{ NULL, NULL, 0, 0, 0, 0}
};
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC] Add support for .debug_gdb_scripts to mach-o. 2011-12-28 0:35 [RFC] Add support for .debug_gdb_scripts to mach-o Doug Evans @ 2011-12-31 20:11 ` Iain Sandoe 2012-01-01 19:07 ` Iain Sandoe 0 siblings, 1 reply; 3+ messages in thread From: Iain Sandoe @ 2011-12-31 20:11 UTC (permalink / raw) To: Doug Evans; +Cc: gdb-patches, binutils Hi Doug, On 28 Dec 2011, at 00:23, Doug Evans wrote: > I have no means of testing this. bfd/binutils is pretty good with i686-apple-darwin9 as a target (and gas is gradually getting there); .. gdb also builds for that target with the mods noted below. > And it's not clear that adding .debug_gdb_scripts to > dwarf_section_names_xlat > is reasonable. It seems the right place to me... > Can anyone using mach-o test this, .. in its own right, it builds, but needs the following to add it to GAS: diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c index 74fb0c9..97762f8 100644 --- a/gas/config/obj-macho.c +++ b/gas/config/obj-macho.c @@ -526,7 +526,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-*. @@ -823,6 +824,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. */ > 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. I suppose we should .. but not sure when it will hit the top of the TODO ;) === However, in the interim, Darwin's [native] ld supports creating a section from a file. (so there's a non-assembler way of doing this too). from darwin's man ld: Options that control additional content -sectcreate segname sectname file The section sectname in the segment segname is created from the contents of file file. The combination of segname and sectname must be unique D there cannot already be a section (segname,sectname) from any other input. ... so the following ought to work ... ld -sectcreate __DWARF __debug_gdb_scr python-script-file.py (will try to fit in a look at this, at some stage - one would need http://sourceware.org/ml/gdb-patches/2011-12/msg00890.html as well, to make it build). cheers Iain ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] Add support for .debug_gdb_scripts to mach-o. 2011-12-31 20:11 ` Iain Sandoe @ 2012-01-01 19:07 ` Iain Sandoe 0 siblings, 0 replies; 3+ messages in thread From: Iain Sandoe @ 2012-01-01 19:07 UTC (permalink / raw) To: Doug Evans, Tristan Gingold; +Cc: gdb-patches, binutils Development 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 } ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-01-01 19:07 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-12-28 0:35 [RFC] Add support for .debug_gdb_scripts to mach-o Doug Evans 2011-12-31 20:11 ` Iain Sandoe 2012-01-01 19:07 ` Iain Sandoe
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox