* [PATCH/RFC] Move the cmdarg before load execarg
@ 2011-01-28 9:28 Hui Zhu
2011-01-28 9:58 ` Jan Kratochvil
0 siblings, 1 reply; 7+ messages in thread
From: Hui Zhu @ 2011-01-28 9:28 UTC (permalink / raw)
To: gdb-patches ml
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 ();
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH/RFC] Move the cmdarg before load execarg
2011-01-28 9:28 [PATCH/RFC] Move the cmdarg before load execarg Hui Zhu
@ 2011-01-28 9:58 ` Jan Kratochvil
2011-01-28 12:25 ` Tom Tromey
0 siblings, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2011-01-28 9:58 UTC (permalink / raw)
To: Hui Zhu; +Cc: gdb-patches ml
On Fri, 28 Jan 2011 07:41:22 +0100, Hui Zhu wrote:
> 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?
It apparently breaks the much more common case of:
gdb program -ex 'b main'
You should just use:
gdb -q -ex "set gnutarget elf32-littlearm" -ex "file ./vmlinux"
as changing options required before the image load is generally an advanced
topic so I guess the "file" command requirement is OK in such case.
Thanks,
Jan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH/RFC] Move the cmdarg before load execarg
2011-01-28 9:58 ` Jan Kratochvil
@ 2011-01-28 12:25 ` Tom Tromey
2011-01-30 0:52 ` Hui Zhu
0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2011-01-28 12:25 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Hui Zhu, gdb-patches ml
>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
Jan> It apparently breaks the much more common case of:
Jan> gdb program -ex 'b main'
FWIW, I think backward compatibility here is more important than whether
or not the options are defined in the best way possible. In this case
it is especially true, since there is a fairly reasonable workaround.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH/RFC] Move the cmdarg before load execarg
2011-01-28 12:25 ` Tom Tromey
@ 2011-01-30 0:52 ` Hui Zhu
2011-01-31 15:03 ` Jan Kratochvil
2011-01-31 15:05 ` Tom Tromey
0 siblings, 2 replies; 7+ messages in thread
From: Hui Zhu @ 2011-01-30 0:52 UTC (permalink / raw)
To: Tom Tromey, Jan Kratochvil; +Cc: gdb-patches ml
On Fri, Jan 28, 2011 at 20:11, Tom Tromey <tromey@redhat.com> wrote:
>>>>>> "Jan" == Jan Kratochvil <jan.kratochvil@redhat.com> writes:
>
> Jan> It apparently breaks the much more common case of:
> Jan> gdb program -ex 'b main'
>
> FWIW, I think backward compatibility here is more important than whether
> or not the options are defined in the best way possible. In this case
> it is especially true, since there is a fairly reasonable workaround.
>
> Tom
>
Agree with you.
Do you think we can add some other options to let gdb exec some
command before load the file?
Cause my gdb support multi-arch, but need "set gnutarget" everytime
when I use it. So I want add a alias in my bashrc like alias
arm-gdb='gdb -ex "set gnutarget"' or a shell to make it works better.
Thanks,
Hui
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH/RFC] Move the cmdarg before load execarg
2011-01-30 0:52 ` Hui Zhu
@ 2011-01-31 15:03 ` Jan Kratochvil
2011-02-08 13:39 ` Hui Zhu
2011-01-31 15:05 ` Tom Tromey
1 sibling, 1 reply; 7+ messages in thread
From: Jan Kratochvil @ 2011-01-31 15:03 UTC (permalink / raw)
To: Hui Zhu; +Cc: Tom Tromey, gdb-patches ml
On Sun, 30 Jan 2011 01:31:46 +0100, Hui Zhu wrote:
> Do you think we can add some other options to let gdb exec some
> command before load the file?
> Cause my gdb support multi-arch, but need "set gnutarget" everytime
> when I use it. So I want add a alias in my bashrc like alias
> arm-gdb='gdb -ex "set gnutarget"' or a shell to make it works better.
~/.gdbinit is read before anything else.
first: mv ~/.gdbinit ~/.gdbinit2
alias arm-gdb='echo -e "set gnutarget elf32-littlearm\nsource ~/.gdbinit2" >~/.gdbinit; /usr/bin/gdb'
alias gdb='echo -e "source ~/.gdbinit2" >~/.gdbinit; /usr/bin/gdb'
Regards,
Jan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH/RFC] Move the cmdarg before load execarg
2011-01-30 0:52 ` Hui Zhu
2011-01-31 15:03 ` Jan Kratochvil
@ 2011-01-31 15:05 ` Tom Tromey
1 sibling, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2011-01-31 15:05 UTC (permalink / raw)
To: Hui Zhu; +Cc: Jan Kratochvil, gdb-patches ml
>> Do you think we can add some other options to let gdb exec some
>> command before load the file?
I view new options with suspicion by default. But, I have not really
thought about this one much, so I can't really say.
>> Cause my gdb support multi-arch, but need "set gnutarget" everytime
>> when I use it. So I want add a alias in my bashrc like alias
>> arm-gdb='gdb -ex "set gnutarget"' or a shell to make it works better.
You can always make a little shell script wrapper that does exactly what
you want.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH/RFC] Move the cmdarg before load execarg
2011-01-31 15:03 ` Jan Kratochvil
@ 2011-02-08 13:39 ` Hui Zhu
0 siblings, 0 replies; 7+ messages in thread
From: Hui Zhu @ 2011-02-08 13:39 UTC (permalink / raw)
To: Jan Kratochvil; +Cc: Tom Tromey, gdb-patches ml
On Mon, Jan 31, 2011 at 19:04, Jan Kratochvil <jan.kratochvil@redhat.com> wrote:
> On Sun, 30 Jan 2011 01:31:46 +0100, Hui Zhu wrote:
>> Do you think we can add some other options to let gdb exec some
>> command before load the file?
>> Cause my gdb support multi-arch, but need "set gnutarget" everytime
>> when I use it. So I want add a alias in my bashrc like alias
>> arm-gdb='gdb -ex "set gnutarget"' or a shell to make it works better.
>
> ~/.gdbinit is read before anything else.
>
> first: mv ~/.gdbinit ~/.gdbinit2
>
> alias arm-gdb='echo -e "set gnutarget elf32-littlearm\nsource ~/.gdbinit2" >~/.gdbinit; /usr/bin/gdb'
> alias gdb='echo -e "source ~/.gdbinit2" >~/.gdbinit; /usr/bin/gdb'
>
>
> Regards,
> Jan
>
Thanks Jan. This way is cool.
Hui
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-02-08 13:39 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-28 9:28 [PATCH/RFC] Move the cmdarg before load execarg Hui Zhu
2011-01-28 9:58 ` Jan Kratochvil
2011-01-28 12:25 ` Tom Tromey
2011-01-30 0:52 ` Hui Zhu
2011-01-31 15:03 ` Jan Kratochvil
2011-02-08 13:39 ` Hui Zhu
2011-01-31 15:05 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).