This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Weird x86 Linux/GNU crashes


% 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]