Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Oct 1995 10:55:29 +1000 (EST)
From:      raoul@cssc-syd.tansu.com.au (Raoul Golan)
To:        julian@ref.tfs.com (Julian Elischer)
Cc:        freebsd-questions@freebsd.org
Subject:   Re: gdb problem?  libraries, perhaps?
Message-ID:  <199510050055.KAA26622@kiwi.cssc-syd.tansu.com.au>
In-Reply-To: <199510040448.VAA01034@ref.tfs.com> from "Julian Elischer" at Oct 3, 95 09:48:56 pm

next in thread | previous in thread | raw e-mail | index | archive | help

Re: stupid problem whereby gdb crashes when run for any executable.

> 
> Got /proc mounted?
> 

Yes, I have.  Thanks for your reply.

I managed to track down the problem by following the gdb source
code last night (kind of difficult seeing that I didn't have
gdb to trace it with ! :-)  

The problem is that my login shell is /bin/csh.  Since I'd rather
use zsh instead, as the last line in my .cshrc I have
"exec /usr/local/bin/zsh" to switch to zsh.  I didn't bother
to change my /etc/passwd entry with chpass, and I thought
I wouldn't need to.

Anyway, I traced it down to a ptrace syscall in the gdb source
code.  The arguments were correct (as far as I could tell), but
the call was failing.  The address referred to for the child process 
was supposedly non-existent (yet I knew that my test program could
access that address without any problems).  VERY strange.

I put in a sleep in the gdb code in the right place, and examined
the process table.  The child process which I expect to be my
test program was actually a zsh.  VERY strange.

I then looked at the code that does the fork in gdb.  I saw
that what is forked is not a new process running the test
program, but a shell exec-ing the test program.  The penny
dropped. The test program was *not* what was being ptraced - a
zsh was being ptraced instead.

Anyway - this is a result of forking off a shell instead
of a process running the test binary.  I removed the 
"exec zsh" from .cshrc, and gdb worked like a charm.

The "exec zsh" shouldn't really be in my .cshrc, but 
I figure that at least some warning should be given about this 
by gdb.  It seems that it's not so much a FreeBSD problem than
a gnu problem.

Raoul



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199510050055.KAA26622>