Solved Unix utilities with DWARF

AlexanderProphet

Active Member

Reaction score: 31
Messages: 145

Hi,
I couldn't find the answer to this on Google... Sorry if the answer is really obvious. I am trying to compile utilities from the /bin/ directory of the Free BSD source code ( such as ls, cat etc) with DWARF debugging information included. Some digging turned up that I should write:
make WITH_DEBUG=yes
Butl that doesn't work. Further digging caused me to add -g option or -gdwarf to CFLAGS in the Makefile. Still no luck; objdump still reports no DWARF information.
Please help, thanks in advance!
PS sorry for lack of formatting ; I am typing this on a mobile phone!
 

ralphbsz

Daemon

Reaction score: 1,005
Messages: 1,627

This forum is mostly populated by users. You probably want to ask on the correct developer mailing list. Normal users are typically not interested in debugging programs in /bin, but developers might be. The reason I said "correct mailing list" is: there is more than one.
 
OP
OP
AlexanderProphet

AlexanderProphet

Active Member

Reaction score: 31
Messages: 145

Hi, thanks for your reply. I don't really get along with mailing lists. I dislike the subscription thing and the lack of privacy. I understand why you recommended them because my questions are a bit hacky but I'd like to avoid lists if at all possible.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 7,289
Messages: 29,732

This is mostly a user support forum, there are very few (FreeBSD) developers here.
 
OP
OP
AlexanderProphet

AlexanderProphet

Active Member

Reaction score: 31
Messages: 145

Yeah I take your point.
But there are posts on here about driver development which have received halp and my question is vastly less technical than those!
So I'm going to wait. At the very least I deserve some sort of smiley face reaction.
 
OP
OP
AlexanderProphet

AlexanderProphet

Active Member

Reaction score: 31
Messages: 145

This is weird. When I compile the ls utility, a file called ls.debug is created, which appears to be or contain DWARF debugging information... however objdump and the file utility both describe it as corrupt in some way.
What fun.
 

Bobi B.

Well-Known Member

Reaction score: 142
Messages: 333

After compiling a binary (a program or a shared library) with debug information, one can use objcopy(1) to copy only debug information in a separate file, usually named after <binary>.debug, then use strip(1) to erase debug information from the <binary> itself.

This way one can distribute binaries and debug symbols separately, or not distribute debug symbols at all. You can still use those .debug files when analysing core dumps at a later time.
 
OP
OP
AlexanderProphet

AlexanderProphet

Active Member

Reaction score: 31
Messages: 145

Bobi B thanks so much for elucidating on this. It really helps.
Do you have any idea why objdump reports "holes" and "overlaps" in the DWARF info? Can I safely ignore this? (I'm writing a debugger).
 

Bobi B.

Well-Known Member

Reaction score: 142
Messages: 333

Bobi B thanks so much for elucidating on this. It really helps.
Do you have any idea why objdump reports "holes" and "overlaps" in the DWARF info? Can I safely ignore this? (I'm writing a debugger).
Unfortunately I'm unable to help you with that. Maybe consulting with some sort of a reference about ELF would help. However you better post an example command line and objdump(1) output, highlighting parts that worry you. Also why would you write a new debugger?
 
OP
OP
AlexanderProphet

AlexanderProphet

Active Member

Reaction score: 31
Messages: 145

Hi there Bobi.
I'm writing a memory debugger because I'm unhappy with valgrind/leaksanitiser. (valgrind seems to have issues finding source code more often than not and only makes vague guesses about leaks; leaksanitiser refuses to even run for me on FreeBSD). I'm going to upload the first version quite soon - I'm just tidying up.
i will post the output of objdump later - it's a bit tricky because I don't have internet atm except on my phone...
 
OP
OP
AlexanderProphet

AlexanderProphet

Active Member

Reaction score: 31
Messages: 145

So it turns out the DWARF information in the *.debug files is almost identical to what you would get if you opted to store it in the main binary.
The only significant difference (presumably due to objcopy) is that some of the debug information entries have their attributes in reverse order.
How do I mark this as solved?
 
Top