WebCore::Garbage Collector::How to get stack base address

hi,

I am working for the porting of web browser on qnx.
On qnx platform how can I get the stack base address if i have thread id of the thread. On qnx pthread_getattr_np(thread, &sattr); is not supported as it is non-POSIX API
This also doesnt work::pthread_attr_getstacksize(&sattr,&stackSize);

Is there any API or any other way in which i cud get stack base address and the stack size…from thread ID?? IF then do reply :blush:

This is the particular function in which my code for collector.cpp gives memory dump.

static inline void* currentThreadStackBase()
{
#if PLATFORM(DARWIN)
pthread_t thread = pthread_self();
return pthread_get_stackaddr_np(thread);
#elif PLATFORM(WIN_OS) && PLATFORM(X86) && COMPILER(MSVC)
// offset 0x18 from the FS segment register gives a pointer to
// the thread information block for the current thread
NT_TIB* pTib;
__asm {
MOV EAX, FS:[18h]
MOV pTib, EAX
}
return (void*)pTib->StackBase;
#elif PLATFORM(WIN_OS) && PLATFORM(X86_64) && COMPILER(MSVC)
PNT_TIB64 pTib = reinterpret_cast<PNT_TIB64>(NtCurrentTeb());
return (void*)pTib->StackBase;
#elif PLATFORM(WIN_OS) && PLATFORM(X86) && COMPILER(GCC)
// offset 0x18 from the FS segment register gives a pointer to
// the thread information block for the current thread
NT_TIB* pTib;
asm ( “movl %%fs:0x18, %0\n”
: “=r” (pTib)
);
return (void*)pTib->StackBase;
#elif PLATFORM(SOLARIS)
stack_t s;
thr_stksegment(&s);
return s.ss_sp;
#elif PLATFORM(UNIX)
static void* stackBase = 0;
static size_t stackSize = 0;
static pthread_t stackThread;
pthread_t thread = pthread_self();
if (stackBase == 0 || thread != stackThread) {
pthread_attr_t sattr;
[color=red] pthread_attr_init(&sattr);
#if HAVE(PTHREAD_NP_H)
// e.g. on FreeBSD 5.4, neundorf@kde.org
pthread_attr_get_np(thread, &sattr);
#elif defined(QNXNTO)
[color=green]pthread_attr_getstacksize(&sattr,&stackSize);
#else
// FIXME: this function is non-portable; other POSIX systems may have different np alternatives
[color=green] pthread_getattr_np(thread, &sattr);
#endif
[size=150] int rc = pthread_attr_getstack(&sattr, &stackBase, &stackSize);[/size]
//This gives stackbase NULL;
(void)rc; // FIXME: Deal with error code somehow? Seems fatal.
ASSERT(stackBase);
pthread_attr_destroy(&sattr);
stackThread = thread;
}
return static_cast<char*>(stackBase) + stackSize;
#else
#error [color=red]Need a way to get the stack base on this platform
#endif
}

Red color function works properly,
But green color function doent work wat i suppose…

PLz help me how to get rid from this problem…
Thanx in Advance… :unamused: