[PATCH/RFC] Move the cmdarg before load execarg

Hui Zhu
2011-01-28T06:41:52Z

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 <teawater@gmail.com>

* 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 ();