Hello, Genode
I'm trying to understand how env() and env()->parent() work from the source
code.
First, I find the body of env function located at:
genode/base/src/base/env/env.cc
and looks like this:
namespace Genode {
/*
* Request pointer to static environment of the Genode application
*/
Env *env()
{
/*
* By placing the environment as static object here, we ensure
that its
* constructor gets called when this function is used the first
time.
*/
static Genode::Platform_env _env;
return &_env;
}
}
env() function looks like, at namespace Genode, it returns the pointer of
singleton object _env (static Genode::Platform_env _env).
But, when I call env() at different places, it returns different addresses.
For instance,
- at genode/base/src/core/main.cc
- at dde_linux/src/drivers/usb/nic/nic.cc,
env() function returns different addresses like the following
- at genode/base/src/core/main.cc, it returns 801f01a0
- at dde_linux/src/drivers/usb/nic/nic.cc, it returns 10b716c.
For me, it is very strange, because both functions returns the address of a
singleton object _env.
I think I miss some points and appreciate if you fill the gap.
And, one more thing: I was trying to print some debug message at Env *env()
function like the following.
Env *env()
{
/*
* By placing the environment as static object here, we ensure
that its
* constructor gets called when this function is used the first
time.
*/
static Genode::Platform_env _env;
PDBG("Genode::env() function called"); // my debug message
return &_env;
}
And, when I run the genode, it always halt at core and child init is not
running.
Do you have any clues?
Thanks always,
Jaeyong