diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2009-08-12 18:28:22 (GMT) |
---|---|---|
committer | Kent Hansen <khansen@trolltech.com> | 2009-09-04 10:41:02 (GMT) |
commit | c39c4a561e5aa65eb50df3936f41ee9d76c6929a (patch) | |
tree | e13c9a43848151b6472a58126b0cd29196a544b8 /src | |
parent | c276d17b7ca99100a9421e848516af02dd8c2b92 (diff) | |
download | Qt-c39c4a561e5aa65eb50df3936f41ee9d76c6929a.zip Qt-c39c4a561e5aa65eb50df3936f41ee9d76c6929a.tar.gz Qt-c39c4a561e5aa65eb50df3936f41ee9d76c6929a.tar.bz2 |
Add a way of getting the stack base on HP-UX.
Unfortunately, HP-UX's pthread doesn't allow us to get the stack
address of a running thread. We have to suspend the thread. And
obviously we can't suspend ourselves.
The solution is to start another thread, which suspends us, gets the
stack address, and resumes.
Diffstat (limited to 'src')
-rw-r--r-- | src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp b/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp index b8c91d1..1268d3d 100644 --- a/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/runtime/Collector.cpp @@ -506,6 +506,49 @@ static void* getStackBase(void* previousFrame) } } #endif +#if PLATFORM(HPUX) +struct hpux_get_stack_base_data +{ + pthread_t thread; + _pthread_stack_info info; +}; + +static void *hpux_get_stack_base_internal(void *d) +{ + hpux_get_stack_base_data *data = static_cast<hpux_get_stack_base_data *>(d); + + // _pthread_stack_info_np requires the target thread to be suspended + // in order to get information about it + pthread_suspend(data->thread); + + // _pthread_stack_info_np returns an errno code in case of failure + // or zero on success + if (_pthread_stack_info_np(data->thread, &data->info)) { + // failed + return 0; + } + + pthread_continue(data->thread); + return data; +} + +static void *hpux_get_stack_base() +{ + hpux_get_stack_base_data data; + data.thread = pthread_self(); + + // We cannot get the stack information for the current thread + // So we start a new thread to get that information and return it to us + pthread_t other; + pthread_create(&other, 0, hpux_get_stack_base_internal, &data); + + void *result; + pthread_join(other, &result); + if (result) + return data.info.stk_stack_base; + return 0; +} +#endif static inline void* currentThreadStackBase() { @@ -532,6 +575,8 @@ static inline void* currentThreadStackBase() : "=r" (pTib) ); return static_cast<void*>(pTib->StackBase); +#elif PLATFORM(HPUX) + return hpux_get_stack_base(); #elif PLATFORM(SOLARIS) stack_t s; thr_stksegment(&s); |