I'm in the midst of debugging a snoop implementation and I wanted to recompile with gcc and use gdb. I saved the output from the make command and basically used vi to put each .o file on a single line:
[th199096@jhereg snoop]> more files.make nfs4_xdr.o snoop.o snoop_aarp.o snoop_adsp.o snoop_aecho.o snoop_apple.o
Note that I could strip off the '.o's manually, but typically I would leave them there. What I want to do is take the filename and use it twice in command. I.e.
% gcc -g -c -o nfs4_xdr.o nfs4_xdr.c
So I decided to use Python to learn a bit more about it:
[th199096@jhereg snoop]> more tran.py
#!/usr/sfw/bin/python
l1 = []
print "#!/bin/sh -x"
print "# Make no changes here, machine generated!"
print "rm snoop *.o"
for line in open("files.make"):
[name, ext] = line.split('.')
print "gcc -g -DUSE_FOR_SNOOP -c -I/builds/th199096/snoop/proto/root_i386/usr/include" \
" -I. -I/builds/th199096/snoop/usr/src/common/net/dhcp -o %s.o %s.c" % (name, name)
l1.append(name)
print 'gcc -g -DTEXT_DOMAIN="SUNW_OST_OSCMD" -D_TS_ERRN -Bdirect -o snoop ',
for name in l1:
print "%s.o" % (name),
print "-L/builds/th199096/snoop/proto/root_i386/lib -L/builds/th199096/snoop/proto/root_i386/usr/lib" \
" -ldhcputil -ldlpi -lsocket -lnsl -ltsol"
One thing that jumped out was since I threw away the 'ext', I didn't have to worry abotu stripping off the '\n'. I also made use of the ',' on the end of the print statements to keep a line going.
I liked the ease of adding to the list of filenames. And in general, I found it easy to make a quick change and retest.
Could I have done this another way, say with the Makefile? Sure, but it wouldn't have been a learning experience. And off I go, the gdb prompt is calling me!
good info about this problem
Posted by rapidshare search on April 05, 2009 at 03:36 PM CDT #