From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22429 invoked by alias); 28 Jan 2011 06:41:52 -0000 Received: (qmail 22419 invoked by uid 22791); 28 Jan 2011 06:41:51 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-gw0-f41.google.com (HELO mail-gw0-f41.google.com) (74.125.83.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 28 Jan 2011 06:41:44 +0000 Received: by gwj22 with SMTP id 22so1196643gwj.0 for ; Thu, 27 Jan 2011 22:41:43 -0800 (PST) Received: by 10.150.146.1 with SMTP id t1mr3912734ybd.236.1296196902847; Thu, 27 Jan 2011 22:41:42 -0800 (PST) MIME-Version: 1.0 Received: by 10.147.168.6 with HTTP; Thu, 27 Jan 2011 22:41:22 -0800 (PST) From: Hui Zhu Date: Fri, 28 Jan 2011 09:28:00 -0000 Message-ID: Subject: [PATCH/RFC] Move the cmdarg before load execarg To: gdb-patches ml Content-Type: text/plain; charset=ISO-8859-1 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: 2011-01/txt/msg00530.txt.bz2 Hi, I got following trouble: gdb -q -ex "set gnutarget elf32-littlearm" ./vmlinux "/home/teawater/kernel/barm_versatile_926ejs/vmlinux": not in executable format: File format is ambiguous. Matching formats: elf32-littlearm elf32-littlearm-symbian elf32-littlearm-vxworks. Use "set gnutarget format-name" to specify the format. Even if I use -ex to exec the command to set the gnutarget, but it is useless because cmdarg is exec after the vmlinux load. I think -ex should have more high level than others. So I make a patch let it exec before load execarg. What do you think about it? Thanks, Hui 2011-01-28 Hui Zhu * main.c (captured_main): Move the cmdarg code. --- main.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) --- a/main.c +++ b/main.c @@ -823,6 +823,17 @@ captured_main (void *data) catch_command_errors (directory_switch, dirarg[i], 0, RETURN_MASK_ALL); xfree (dirarg); + for (i = 0; i < ncmd; i++) + { + if (cmdarg[i].type == CMDARG_FILE) + catch_command_errors (source_script, cmdarg[i].string, + !batch_flag, RETURN_MASK_ALL); + else /* cmdarg[i].type == CMDARG_COMMAND */ + catch_command_errors (execute_command, cmdarg[i].string, + !batch_flag, RETURN_MASK_ALL); + } + xfree (cmdarg); + /* Skip auto-loading section-specified scripts until we've sourced local_gdbinit (which is often used to augment the source search path). */ @@ -900,17 +911,6 @@ captured_main (void *data) ALL_OBJFILES (objfile) load_auto_scripts_for_objfile (objfile); - for (i = 0; i < ncmd; i++) - { - if (cmdarg[i].type == CMDARG_FILE) - catch_command_errors (source_script, cmdarg[i].string, - !batch_flag, RETURN_MASK_ALL); - else /* cmdarg[i].type == CMDARG_COMMAND */ - catch_command_errors (execute_command, cmdarg[i].string, - !batch_flag, RETURN_MASK_ALL); - } - xfree (cmdarg); - /* Read in the old history after all the command files have been read. */ init_history ();