From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18712 invoked by alias); 16 Apr 2010 07:13:53 -0000 Received: (qmail 18700 invoked by uid 22791); 16 Apr 2010 07:13:51 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,TW_BJ,TW_YM,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Apr 2010 07:13:47 +0000 Received: from kpbe14.cbf.corp.google.com (kpbe14.cbf.corp.google.com [172.25.105.78]) by smtp-out.google.com with ESMTP id o3G7DjBe027879 for ; Fri, 16 Apr 2010 00:13:45 -0700 Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.18.118.116]) by kpbe14.cbf.corp.google.com with ESMTP id o3G7Di2V008129 for ; Fri, 16 Apr 2010 00:13:44 -0700 Received: by ruffy.mtv.corp.google.com (Postfix, from userid 67641) id DF64E84396; Fri, 16 Apr 2010 00:13:43 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [RFA] [2/2] .debug_gdb_scripts: defer main symfile auto-loading Message-Id: <20100416071343.DF64E84396@ruffy.mtv.corp.google.com> Date: Fri, 16 Apr 2010 07:13:00 -0000 From: dje@google.com (Doug Evans) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00501.txt.bz2 This patch is a follow-up to http://sourceware.org/ml/gdb-patches/2010-04/msg00500.html The problem being solved is that we want to read in the main symfile before reading ./.gdbinit: The latter may make use of symbols in the main symfile. However, it is common to add to the source search path in ./.gdbinit, and this search path is also used for scripts, including scripts mentioned in .debug_gdb_scripts. So this patch defers auto-loading of scripts in the main symfile at startup until after ./.gdbinit has been sourced. Comments? 2010-04-15 Doug Evans * main.c: #include "python/python.h". (captured_main): Defer loading auto-loaded scripts until after local_gdbinit has been sourced. * python/py-auto-load.c (gdbpy_auto_load): Make externally visible. (load_auto_scripts_for_objfile): New function. (auto_load_new_objfile): Call it. * python/python.h (gdbpy_auto_load): Declare. (load_auto_scripts_for_objfile): Declare. diff -pN -U 2 ../../p6/src/gdb/./main.c gdb/./main.c --- ../../p6/src/gdb/./main.c 2010-04-08 23:28:52.000000000 -0700 +++ gdb/./main.c 2010-04-15 21:40:02.000000000 -0700 @@ -42,4 +42,5 @@ #include "source.h" #include "cli/cli-cmds.h" +#include "python/python.h" /* If nonzero, display time usage both at startup and for each command. */ @@ -292,4 +293,5 @@ captured_main (void *data) int i; + int save_auto_load; long time_at_startup = get_run_time (); @@ -799,4 +801,9 @@ Excess command line arguments ignored. ( xfree (dirarg); + /* Skip auto-loading section-specified scripts until we've sourced + local_gdbinit (which is often used to augment the source search path). */ + save_auto_load = gdbpy_auto_load; + gdbpy_auto_load = 0; + if (execarg != NULL && symarg != NULL @@ -858,4 +865,12 @@ Can't attach to process and specify a co catch_command_errors (source_script, local_gdbinit, 0, RETURN_MASK_ALL); + /* Now that all .gdbinit's have been read and all -d options have been + processed, we can read any scripts mentioned in SYMARG. + We wait until now because it is common to add to the source search + path in local_gdbinit. */ + gdbpy_auto_load = save_auto_load; + if (symfile_objfile != NULL) + load_auto_scripts_for_objfile (symfile_objfile); + for (i = 0; i < ncmd; i++) { diff -pN -U 2 ../../p6/src/gdb/./python/py-auto-load.c gdb/./python/py-auto-load.c --- ../../p6/src/gdb/./python/py-auto-load.c 2010-04-15 22:22:54.000000000 -0700 +++ gdb/./python/py-auto-load.c 2010-04-15 23:18:00.000000000 -0700 @@ -69,5 +69,5 @@ struct loaded_script_entry /* This is true if we should auto-load python code when an objfile is opened, false otherwise. */ -static int gdbpy_auto_load = 1; +int gdbpy_auto_load = 1; /* Per-program-space data key. */ @@ -379,8 +379,14 @@ auto_load_new_objfile (struct objfile *o if (gdbpy_auto_load) - { - auto_load_objfile_script (objfile, GDBPY_AUTO_FILE_NAME); - auto_load_section_scripts (objfile, GDBPY_AUTO_SECTION_NAME); - } + load_auto_scripts_for_objfile (objfile); +} + +/* Load any auto-loaded scripts for OBJFILE. */ + +void +load_auto_scripts_for_objfile (struct objfile *objfile) +{ + auto_load_objfile_script (objfile, GDBPY_AUTO_FILE_NAME); + auto_load_section_scripts (objfile, GDBPY_AUTO_SECTION_NAME); } diff -pN -U 2 ../../p6/src/gdb/./python/python.h gdb/./python/python.h --- ../../p6/src/gdb/./python/python.h 2010-04-15 10:55:05.000000000 -0700 +++ gdb/./python/python.h 2010-04-15 21:39:38.000000000 -0700 @@ -23,4 +23,6 @@ #include "value.h" +extern int gdbpy_auto_load; + void eval_python_from_control_command (struct command_line *); @@ -35,3 +37,5 @@ int apply_val_pretty_printer (struct typ void preserve_python_values (struct objfile *objfile, htab_t copied_types); +void load_auto_scripts_for_objfile (struct objfile *objfile); + #endif /* GDB_PYTHON_H */