This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Weird x86 Linux/GNU crashes
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Joe Buck <Joe dot Buck at synopsys dot com>, Andreas Schwab <schwab at suse dot de>
- Cc: "David S. Miller" <davem at redhat dot com>, "hjl at lucon dot org" <hjl at lucon dot org>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Wed, 31 Jul 2002 13:55:57 -0700
- Subject: Re: Weird x86 Linux/GNU crashes
- References: <200207312054.NAA28233@atrus.synopsys.com>
% gdb my_program
(gdb) [ set some breakpoints ]
(gdb) run
he or she has no idea that he has done any "shelling out".
I will not shell out for a debugger that shells out.
Oh, this one's gratis.
Well, I guess I am a sell-out then; I will use this shell-out debugger....
I'm beginning to feel vaguely like I'm in a Dr. Seuss book, so I'll stop...
Even if he types
(gdb) run arg1 arg2 > out_file
s/he has only asked "put my output in out_file", not "destroy my
environment, keep me from finding my shared libraries, and make me
pull all my hair out".
A shell should only be invoked where one is needed, and it should be
invoked if needed in a minimally disruptive way (no reading of shell
startup files).
At minimum, if there are no meta-characters in the "run" command, execv
should be used directly to start the program. It is more efficient and
won't trash the environment.
I couldn't agree more. This was very confusing to me. If my program
runs differently under the debugger than it does from the shell,
the debugger is broken -- with very few exceptions, such as programs
that explicitly check to see whether they're running in a debugger.
If we really need shell functionality in GDB, it would be far better
to link in the relevant bash code and use it directly. I would much
rather make C-shell users use Bourne-shell syntax to do redirections
than create situations where stuff in startup files can change the
behavior of programs run in the debuggger.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com