__builtin_return_address() Error

nitin kumbhar nitin_kumbhar@yahoo.com
Tue Jan 14 13:07:00 GMT 2003


Hi All,
	I have few queries about the gcc's magic functions
__builtin_return_address() 
and __builtin_frame_address().
	I am using gcc version 2.96 20000731 (Red Hat Linux
7.1 2.96-98). The machine is 
with RH 7.2 linux on a P-III processor. I am using
2.4.7-10 kernel version on this.
	My need is to use these functions to back trace the
kernel stack to get return addresses. 
i tried both functions but got little success to get
correct results. Following are the errors
for these functions.

1. __builtin_return_address(level)
	All documents about this function say that it returns
an address depending on level,
if level does not cross the top of the stack otherwise
it returns a NULL.
	But i could not get this result. i am getting "Oops"
when i loop for a NULL value.
In my case the virtual address was 0xbfffcca8. to
check what is this value on the stack, 
i used address of local variable to get the stack
which is as follows. the local variable 
is present in a kernel function called from a module. 

0xc2081ec8:     0xc11d10a0      0xc02ad2c0     
0x00000e02      0x00000282
0xc2081ed8:     0xc11d10a0      0xc481b000     
0x00000000      0x00000000
0xc2081ee8:     0xc2081f08      0xc481b091     
0xc159d44c      0x00000000
0xc2081ef8:     0x00000000      0xc481b000     
0x00000000      0xc159d44c
0xc2081f08:     0xc2081fbc      0xc0119cd9     
0x00000000      0x00000000
0xc2081f18:     0xc02ad4a4      0x0806d2bc     
0xc1c4f000      0x000000a4
0xc2081f28:     0x00000120      0xc1e02000     
0x00000064      0xffffffea
0xc2081f38:     0x0000000a      0xc159d424     
0x00000064      0xc4818000
0xc2081f48:     0xc481b064      0x00000120     
0x00000000      0x00000000
0xc2081f58:     0x00000000      0x00000000     
0x00000000      0x00000000
0xc2081f68:     0x00000000      0x00000000     
0x00000000      0x00000000
0xc2081f78:     0x00000000      0x00000000     
0x00000000      0x00000000
0xc2081f88:     0x00000000      0x00000000     
0x00000000      0x00000000
0xc2081f98:     0x00000000      0x00000000     
0x00000000      0x00000202
0xc2081fa8:     0xc2080000      0x00000004     
0xc2080000      0x0804b0f2
0xc2081fb8:     0x0806bd48      0xbfffcca8     
0xc0106fcb      0x0805f270
0xc2081fc8:     0x0806d218      0xbfffccb8     
0x0804b0f2      0x0806bd48
0xc2081fd8:     0xbfffcca8      0x00000080     
0x0000002b      0x0000002b
0xc2081fe8:     0x00000080      0x420e7c1e     
0x00000023      0x00000246
0xc2081ff8:     0xbfffcc70      0x0000002b     
0x20736425      0x00642525
0xc2082008:     0x6b73614d      0x6b736d00     
0x756d5800      0x6f727245
0xc2082018:     0x76630072      0x72745374     
0x54676e69      0x6c6f436f
0xc2082028:     0x7543726f      0x726f7372     
0x746f6200      0x006d6f74
0xc2082038:     0x68676972      0x6f740074     
0x656c0070      0x75007466
0xc2082048:     0x70616d6e      0x61747300     
0x00636974      0x74756f73

	From this i could not guess whats that value. can
someone help me to solve this problem?
am i wrong at some place using this function?


2. __builtin_frame_address(frame)
	Even for this function it should return a NULL, when
it reaches the top of stack. here  i
am getting a NULL value. But before that i am getting
some frame pointers which when accessed result
in Oops. List of frame addresses is as follows.

frame addr : c2081eac 
frame addr : c2081ec0 
frame addr : c2081ee8 
frame addr : c2081f08 
frame addr : c2081fbc 
frame addr : bfffcca8 
frame addr : bfffeac8 
frame addr : bffffb08 
frame addr : bffffb48 
frame addr : 0
	
	Here also I could not guess what are these values?
are these values garbage i.e. the kernel stack is 
not properly initialized? Or they got some diffrent
meaning? Are these values pushed on to stack because
of 
some kernel calling mechanism? Do these values
represent some kernel frames? What is the kernel stack
frame layout?  

	As i am not member of this list, Please send replies
with  a cc.
	I think this is the right place to get the answer.
Thanks in advance.

Regards,
Nitin  


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



More information about the Gcc-help mailing list