First stab at MINIX-ELF gdb

22 views
Skip to first unread message

Antoine LECA

unread,
Apr 8, 2011, 10:50:54 AM4/8/11
to min...@googlegroups.com
Hi guys,

I had some limited success building gdb (6.8) on the new ELF-enabled
MINIX. It is not yet a full working solution, but it seems to me a base
to continue building. So if anybody is interested, here is the raw material.

First, you need to add some support in the MINIX libc library for two
POSIX-mandated calls which implementation is partly missing, even if the
infrastructure is already there: tc[gs]etpgrp(3). The attached patch is
to be applied to libc/posix; I understand this stuff will be dropped
when NetBSD libc will displace the present one.
Big notice: this patch is just about providing the function calls. The
underlying ioctl is NOT implemented right now in MINIX (in the TTY
driver or elsewhere), as this is probably not an easy task; read
http://groups.google.com/groups?selm=11513.Aug2...@kramden.acf.nyu.edu
for a starter; also
http://groups.google.com/group/minix3/browse_thread/thread/9447061cd32cb147

Next, there are a few bugs or overviews in gdb-6.8 which prevents
smoothless compilation; I tried to reduce it to the bare minimum, but as
my actual source trees are a bit... out of control, plese bear with me
here; also, if you work with another version of gdb, you are expected to
have to adjust this.

Next, you need the real food, i.e. the patches to enable MINIX as gdb
target. This stuff is divided in two, a (fairly straightforward) patch
which adds Minix support at various key points, and the actual added
stuff which spawns four files.

Finally, to build an ELF-targeting gdb you need a ELF-targeting C
compiler; I was not able to complete it with clang (too much waiting and
too much verbose messages on screen, about the code not being cute) so I
used GCC. According to your setup, you can do either:

$ path/to/gdb/configure CC=elfproducing-cross-gcc \
-host=i386-elf -target=i386-elf -disable-shared \
-disable-nls -disable-tui -disable-werror && make

or alternately, if your C compiler is natively ELF:

$ path/to/gdb/configure CC=gcc_or_clang -disable-shared \
-disable-nls -disable-tui -disable-werror && make

Of course, the command line above are short form, you probably better
want to redirect error logs, pause between the steps etc. :-)


Once this is done (lasts about one hour on my VM while using gcc44), it
spits gdb/gdb which you can now try...
The message about "OS ABI FreeBSD" or similar things are because there
are still some mismatches between configuration of the ELF toolchains,
this is under investigation but embrace many things, and AFAIK it only
matters for shared libraries or similar stuff of a level we did not
reach yet; so I ignore it at the moment.
The two messages about tcsetgrp failing are to be expected, see above.
Then I often receive a message about signal SIGEMT, I have not figured
why, help is welcome here :-)

Since you are undoubtly a hacker, now you likely want to enhance that
gdb and make it actually useful! The obvious target for your
investigations will be i386minix-tdep.c, where I basically left the
knobs to the very basic settings, and there are likely much things to
correct there; i386minix-nat.c can probably also be enhanced, but right
now that stuff is just doing basic business with the register file, at a
very mundane level, so there are much less know there unless you want to
add things like FP or hardware breakpoints support.


Another stuff to investigate is ser-tcp.c, where I just looked at it
superficially, discovered GDB assumed non-POSIX BSD-based FIONBIO
implementation, so I tried to fix it with the POSIX way of doing it,
then shifted to other interests and left it just to be able to compile
quietly :-( In fact I just noticed it back while cleaning for this
message; I do not believe this is actually used right now.

While we are on TCP, there is no patch for gdbserver: fact here is that
over the last 5 years or so, the GDB team shifted toward Linux-only
(+Win32 recently) support; so support for systems like *BSD was left out
or put into grey zone, with web-based patches flying around...
I concluded that this need much deeper investigations _later_, and that
it would be easier to do when the native gdb will be working.


Happy hacking!

Antoine

tcxetpgrp.patch
gdb68.patch
gdb68minix.patch
gdb68minix.tar.gz
Reply all
Reply to author
Forward
0 new messages