[PATCH] include/gdb/section-scripts.h: New file.

Doug Evans xdje42@gmail.com
Tue Dec 3 16:17:00 GMT 2013


Doug Evans <xdje42@gmail.com> writes:

> On Mon, Dec 2, 2013 at 7:19 AM, Tom Tromey <tromey@redhat.com> wrote:
>>>>>>> "Doug" == Doug Evans <dje@gmail.com> writes:
>>
>> Doug> This patch creates a file to use when adding values to
>> Doug> .debug_gdb_scripts.
>>
>> I don't see why this needs to go in include.
>
> So you would have code that puts contents in this section using magic numbers?
> Eh? This doesn't make any sense.  Why does dwarf2.def exist (for example) ?
> [The dwarf format is far more complicated, obvously.  But I didn't
> know there was
> a threshold of magic numbers was required before a header was allowed.]
>
>> I think it would be more helpful to document the format of this section
>> in the manual.
>
> Documentation can always be improved, but there is something there already.
> I do need to spiff it up, that's coming ...
>
>> Doug> +/* Native GDB scripts are not currently supported in .debug_gdb_scripts,
>> Doug> +   but we reserve a value for it.  */
>> Doug> +/*#define SECTION_SCRIPT_ID_GDB_FILE 2*/
>>
>> There's no need either to reserve a value or to add commented out code.
>
> I'm curious how I would apply this rule in general.

For reference sake,
here's a patch I want to check in afterwards.

2013-12-03  Doug Evans  <xdje42@gmail.com>

	* auto-load.c: #include "gdb/section-scripts.h".
	(source_section_scripts): Replace magic number.

	testsuite/
	* gdb.python/py-section-script.c: #include "symcat.h",
	"gdb/section-scripts.h".
	* gdb.python/py-section-script.exp: Pass -I${srcdir}/../../include
	to gcc.

diff --git a/gdb/auto-load.c b/gdb/auto-load.c
index 02b08be..0521e3a 100644
--- a/gdb/auto-load.c
+++ b/gdb/auto-load.c
@@ -18,6 +18,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
+#include "gdb/section-scripts.h"
 #include "auto-load.h"
 #include "progspace.h"
 #include "python/python.h"
@@ -895,7 +896,7 @@ source_section_scripts (struct objfile *objfile, const char *section_name,
 	 but that can change.  */
       const struct script_language *language = gdbpy_script_language_defn ();
 
-      if (*p != 1)
+      if (*p != SECTION_SCRIPT_ID_PYTHON_FILE)
 	{
 	  warning (_("Invalid entry in %s section"), section_name);
 	  /* We could try various heuristics to find the next valid entry,
diff --git a/gdb/testsuite/gdb.python/py-section-script.c b/gdb/testsuite/gdb.python/py-section-script.c
index db1daea..b635f13 100644
--- a/gdb/testsuite/gdb.python/py-section-script.c
+++ b/gdb/testsuite/gdb.python/py-section-script.c
@@ -18,10 +18,13 @@
 /* Put the path to the pretty-printer script in .debug_gdb_scripts so
    gdb will automagically loaded it.  */
 
+#include "symcat.h"
+#include "gdb/section-scripts.h"
+
 #define DEFINE_GDB_SCRIPT(script_name) \
   asm("\
 .pushsection \".debug_gdb_scripts\", \"MS\",@progbits,1\n\
-.byte 1\n\
+.byte " XSTRING (SECTION_SCRIPT_ID_PYTHON_FILE) "\n\
 .asciz \"" script_name "\"\n\
 .popsection \n\
 ");
diff --git a/gdb/testsuite/gdb.python/py-section-script.exp b/gdb/testsuite/gdb.python/py-section-script.exp
index 66f1117..945647d 100644
--- a/gdb/testsuite/gdb.python/py-section-script.exp
+++ b/gdb/testsuite/gdb.python/py-section-script.exp
@@ -39,7 +39,7 @@ set remote_python_file [gdb_remote_download host \
 set quoted_name "\"$remote_python_file\""
 
 if {[build_executable $testfile.exp $testfile $srcfile \
-	 [list debug additional_flags=-DSCRIPT_FILE=$quoted_name]] == -1} {
+	 [list debug "additional_flags=-I${srcdir}/../../include -DSCRIPT_FILE=$quoted_name"]] == -1} {
     return -1
 }
 



More information about the Gdb-patches mailing list