Re: pointer address is physical or virtual.
- From: "Prasad" <prasadjoshi124@xxxxxxxxx>
- Date: 15 Dec 2006 07:07:53 -0800
Okay, I will post the thing which confussed me.
This is the program i am executing which used instrument-function
facility of GCC.
(it adds two function which are called automatically when any function
begins its execution and exits its execution.)
[Prasad@prasadjoshi test]$ cat instrument_functions.c
#include<stdio.h>
void __cyg_profile_func_enter (void *this_fn, void *call_site)
__attribute__ ((no_instrument_function)) ;
void __cyg_profile_func_exit (void *this_fn, void *call_site)
__attribute__ ((no_instrument_function)) ;
void afun ()
{
printf ( "In afun ().\n" );
}
int main ()
{
int i = 0;
printf ( "In Main.\n" ) ;
afun () ;
i = 10 ;
while (1) ;
}
void __cyg_profile_func_enter (void *this_fn, void *call_site)
{
printf ( "In Entry Function.\t" ) ;
printf ( "Pointer : %p\n", this_fn ) ;
}
void __cyg_profile_func_exit (void *this_fn, void *call_site)
{
printf ( "In Exit Function.\t" ) ;
printf ( "Pointer : %p\n", this_fn ) ;
}
[Prasad@prasadjoshi test]$ gcc instrument_functions.c -o
instrument_functions1 -finstrument-functions
[Prasad@prasadjoshi test]$ gcc instrument_functions.c -o
instrument_functions -finstrument-functions
Created two copies of it for simultaneous execution, ran them from two
different terminals
[Prasad@prasadjoshi test]$ ./instrument_functions
In Entry Function. Pointer : 0x804844e
In Main.
In Entry Function. Pointer : 0x8048414
In afun ().
In Exit Function. Pointer : 0x8048414
[Prasad@prasadjoshi test]$ ./instrument_functions1
In Entry Function. Pointer : 0x804844e
In Main.
In Entry Function. Pointer : 0x8048414
In afun ().
In Exit Function. Pointer : 0x8048414
Now, I am not getting how could these both processes where loaded in
the same memory as they are having same addresses for the functions?
To add to the confussion, i tried with nm utility.
[Prasad@prasadjoshi test]$ nm instrument_functions | grep -i 804844e
0804844e T main
[Prasad@prasadjoshi test]$ nm instrument_functions | grep -i 8048414
08048414 T afun
Now, I am not getting how could the main() and afun() addresses print
by nm utility are same as the one printed by executing process.
So finally I have two questions.
1. Whether addresses printed from user program are virtual one or
physicall one.
( if they are physicall then how could thes two processes are loaded in
same memory).
2. and what nm utility prints ==> virtyal addresses or physicall one.
( i know this is a disk file and whree the program is loaded does not
depend on it but, still. )
Thanks and regards.
Praasd
Hadron wrote:
"Prasad" <prasadjoshi124@xxxxxxxxx> writes:
Hi All,
When we create a pointer o say an integer variable or a function. And
then print it what it should print?
Address in the physical memory where it is stored or virtual address?
Thanks and regards,
Prasad.
It depends on what the reader needs.
You might convert it to text! "Pointer 1 is to the function Foo" for
example.
.
- References:
- pointer address is physical or virtual.
- From: Prasad
- Re: pointer address is physical or virtual.
- From: Hadron
- pointer address is physical or virtual.
- Prev by Date: Re: pointer address is physical or virtual.
- Next by Date: Re: pointer address is physical or virtual.
- Previous by thread: Re: pointer address is physical or virtual.
- Next by thread: Re: pointer address is physical or virtual.
- Index(es):
Relevant Pages
|