This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Fix "Segmentation fault" when "gdb -v"
On Thu, Mar 4, 2010 at 15:26, Joel Brobecker <brobecker@adacore.com> wrote:
>> All of this code use "printf_filtered". ?But this function must be
>> call after "interp_set".
>> But this part of code call before "interp_set".
>
> I think that this was an unforseen side-effect of a recent change.
> IMO, it's better to get rid of this side-effect (needing the interpreter
> to be set) in printf_filtered.
>
> We should NOT change printf_filtered into printf_unfiltered in this case
> because the same function is used in two different situations:
> ?- when the user uses -v
> ?- when the user types "show version"
> In the latter case, the printf_filtered is appropriate.
>
> Now, we need to decide whether pagination should be enabled if
> the interpreter is not set. I think it makes sense to disable pagination
> in this case. ?If the interpreter is not set yet, we're just printing
> stuff on stdout, we haven't started the interactive session (if any) yet...
>
The way is make it output after interp_set.
Thanks,
Hui
2010-03-04 Hui Zhu <teawater@gmail.com>
* main.c (captured_main): Change version output after
interp_set.
---
main.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
--- a/main.c
+++ b/main.c
@@ -695,19 +695,6 @@ Excess command line arguments ignored. (
gdb_init. */
get_init_files (&system_gdbinit, &home_gdbinit, &local_gdbinit);
- /* Do these (and anything which might call wrap_here or *_filtered)
- after initialize_all_files() but before the interpreter has been
- installed. Otherwize the help/version messages will be eaten by
- the interpreter's output handler. */
-
- if (print_version)
- {
- print_gdb_version (gdb_stdout);
- wrap_here ("");
- printf_filtered ("\n");
- exit (0);
- }
-
if (print_help)
{
print_gdb_help (gdb_stdout);
@@ -750,6 +737,19 @@ Excess command line arguments ignored. (
}
}
+ /* Do these (and anything which might call wrap_here or *_filtered)
+ after initialize_all_files() but before the interpreter has been
+ installed. Otherwize the help/version messages will be eaten by
+ the interpreter's output handler. */
+
+ if (print_version)
+ {
+ print_gdb_version (gdb_stdout);
+ wrap_here ("");
+ printf_filtered ("\n");
+ exit (0);
+ }
+
/* FIXME: cagney/2003-02-03: The big hack (part 2 of 2) that lets
GDB retain the old MI1 interpreter startup behavior. Output the
copyright message after the interpreter is installed when it is