You are not logged in.

#1 2013-07-03 07:19:36

joker_hao
Member
Registered: 2013-07-03
Posts: 3

[Solved]Is there anyone knows how to debug hdparm with GDB?

Hi ,

I downloaded the source codes of hdparm 9.43 and trying to trace the routine with GDB. I modified the Makefile, make clean and make all again.
But after that I always can't find any debug symbols within executable hdparm like following output.

root@debian:/tools/hdparm-9.43# nm hdparm
nm: hdparm: no symbols

Here's my Makefile:

root@debian:/tools/hdparm-9.43# diff Makefile Makefile_mod
13,14c13,15
< CC ?= gcc
< STRIP ?= strip
---
> CC ?= gcc
> #STRIP ?= strip
> STRIP ?=
16c17
< CFLAGS := -O2 -W -Wall -Wbad-function-cast -Wcast-align -Wpointer-arith -Wcast-qual -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fkeep-inline-functions -Wwrite-strings -Waggregate-return -Wnested-externs -Wtrigraphs $(CFLAGS)
---
> CFLAGS := -W -Wall  -ggdb -O1 -Wbad-function-cast -Wcast-align -Wpointer-arith -Wcast-qual -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -fkeep-inline-functions -Wwrite-strings -Waggregate-return -Wnested-externs -Wtrigraphs
18,19c19,20
< LDFLAGS = -s
< #LDFLAGS = -s -static
---
> #LDFLAGS = -s
> LDFLAGS =  -ggdb -O1 -s -static
30,31c31,32
<       $(CC) $(LDFLAGS) -o hdparm $(OBJS)
<       $(STRIP) hdparm
---
>       $(CC) $(LDFLAGS) -o hdparm $(OBJS)
> #$(STRIP) hdparm


I also tried -g but doesn't work sad
is there someone know how to compiled hdparm with debug symbols ? 

Thanks
Hao

Last edited by joker_hao (2013-07-03 09:24:36)

Offline

#2 2013-07-03 07:24:51

joker_hao
Member
Registered: 2013-07-03
Posts: 3

Re: [Solved]Is there anyone knows how to debug hdparm with GDB?

Sorry, my gcc version 4.7.1 (Debian 4.7.1-7)

Offline

#3 2013-07-03 08:55:15

SahibBommelig
Member
From: Germany
Registered: 2010-05-28
Posts: 80

Re: [Solved]Is there anyone knows how to debug hdparm with GDB?

-ggdb should go to CFLAGS only (althouth it won't do harm probably in LDFLAGS). Also remove -s (which will strip debug symbols) from the LDFLAGS.

Offline

#4 2013-07-03 09:00:26

Shark
Member
From: /dev/zero
Registered: 2011-02-28
Posts: 686

Re: [Solved]Is there anyone knows how to debug hdparm with GDB?

Look here.


If you have built castles in the air, your work need not be lost; that is where they should be. Now put foundations under them.
Henry David Thoreau

Registered Linux User: #559057

Offline

#5 2013-07-03 09:21:46

joker_hao
Member
Registered: 2013-07-03
Posts: 3

Re: [Solved]Is there anyone knows how to debug hdparm with GDB?

SahibBommelig wrote:

-ggdb should go to CFLAGS only (althouth it won't do harm probably in LDFLAGS). Also remove -s (which will strip debug symbols) from the LDFLAGS.

Oh, I am so fool,

root@debian:/tools/hdparm-9.43#ld --help
....
  -s, --strip-all             Strip all symbols

I removed the -s from LDFLAGS, it finally does the work !

Thank you smile

Offline

Board footer

Powered by FluxBB