base: add 'Thread::mystack() function

The static 'Thread::mystack()' function returns the stack boundaries of
the calling thread. It is useful when a thread uses a diffent stack than
the primary one.

Fixes #2037
This commit is contained in:
Christian Prochaska 2016-06-29 18:23:39 +02:00 committed by Norman Feske
parent bea48b636e
commit 29a12ab9a2
4 changed files with 25 additions and 9 deletions

View File

@ -51,6 +51,8 @@ class Genode::Thread
typedef Cpu_session::Name Name;
typedef Cpu_session::Weight Weight;
struct Stack_info { addr_t base; addr_t top; };
private:
/**
@ -319,14 +321,14 @@ class Genode::Thread
Native_thread &native_thread();
/**
* Return top of stack
* Return top of primary stack
*
* \return pointer just after first stack element
*/
void *stack_top() const;
/**
* Return base of stack
* Return base of primary stack
*
* \return pointer to last stack element
*/
@ -354,6 +356,11 @@ class Genode::Thread
*/
static Thread *myself();
/**
* Return information about the current stack
*/
static Stack_info mystack();
/**
* Ensure that the stack has a given size at the minimum
*

View File

@ -190,6 +190,14 @@ void *Thread::stack_base() const { return (void*)_stack->base(); }
void Thread::stack_size(size_t const size) { _stack->size(size); }
Thread::Stack_info Thread::mystack()
{
addr_t base = Stack_allocator::addr_to_base(&base);
Stack *stack = Stack_allocator::base_to_stack(base);
return { stack->base(), stack->top() };
}
size_t Thread::stack_virtual_size()
{
return Genode::stack_virtual_size();

View File

@ -1 +1 @@
9ad059d85f8ad1282da3e939b5f187173b580ab2
2db8119ea245fc40501d00968f364e0092a7f090

View File

@ -12,10 +12,10 @@ From: Christian Prochaska <christian.prochaska@genode-labs.com>
qtwebkit/Source/WTF/wtf/OSAllocatorPosix.cpp | 13 ++++++++++++
qtwebkit/Source/WTF/wtf/OSRandomSource.cpp | 8 ++++++++
qtwebkit/Source/WTF/wtf/Platform.h | 19 +++++++++++++++---
qtwebkit/Source/WTF/wtf/StackBounds.cpp | 12 +++++++++++
qtwebkit/Source/WTF/wtf/StackBounds.cpp | 13 ++++++++++++
qtwebkit/Source/WTF/wtf/TCSystemAlloc.cpp | 21 ++++++++++++++++++++
.../platform/graphics/qt/MediaPlayerPrivateQt.cpp | 3 +++
11 files changed, 96 insertions(+), 6 deletions(-)
11 files changed, 97 insertions(+), 6 deletions(-)
diff --git a/qtwebkit/Source/JavaScriptCore/dfg/DFGOperations.cpp b/qtwebkit/Source/JavaScriptCore/dfg/DFGOperations.cpp
index bb9ccc3..077cbed 100644
@ -236,7 +236,7 @@ index 35fa7e3..89e6205 100644
/* Setting this flag compares JIT results with interpreter results. */
diff --git a/qtwebkit/Source/WTF/wtf/StackBounds.cpp b/qtwebkit/Source/WTF/wtf/StackBounds.cpp
index a272ce3..a2e7484 100644
index a272ce3..65a5a1f 100644
--- a/qtwebkit/Source/WTF/wtf/StackBounds.cpp
+++ b/qtwebkit/Source/WTF/wtf/StackBounds.cpp
@@ -44,6 +44,10 @@
@ -250,7 +250,7 @@ index a272ce3..a2e7484 100644
#elif OS(UNIX)
#include <pthread.h>
@@ -128,6 +132,14 @@ void StackBounds::initialize()
@@ -128,6 +132,15 @@ void StackBounds::initialize()
m_bound = estimateStackBound(m_origin);
}
@ -258,8 +258,9 @@ index a272ce3..a2e7484 100644
+
+void StackBounds::initialize()
+{
+ m_bound = Genode::Thread::myself()->stack_base();
+ m_origin = Genode::Thread::myself()->stack_top();
+ Genode::Thread::Stack_info stack_info = Genode::Thread::mystack();
+ m_bound = (void*)stack_info.base;
+ m_origin = (void*)stack_info.top;
+}
+
#elif OS(UNIX)