* Fix the stack allocation code so that it works for alpha. Change it

to use mmap(..., MAP_STACK, ...) on alpha too since that should work
  now.
* Add hooks to allow GDB to access the internals of pthreads without
  having to know the exact layout of struct pthread.

Reviewed by: deischen
This commit is contained in:
Doug Rabson 1999-11-28 19:47:43 +00:00
parent 6f940b3847
commit 3c085f72bb
6 changed files with 78 additions and 18 deletions

View File

@ -336,7 +336,8 @@ struct pthread_attr {
*/
#define PTHREAD_STACK_DEFAULT 65536
/* Size of red zone at the end of each stack. */
#define PTHREAD_STACK_GUARD 4096
#define PTHREAD_STACK_GUARD PAGE_SIZE
/*
* Maximum size of initial thread's stack. This perhaps deserves to be larger
* than the stacks of other threads, since many applications are likely to run
@ -466,6 +467,7 @@ struct pthread {
#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115)
u_int32_t magic;
char *name;
u_int64_t uniqueid; /* for gdb */
/*
* Lock for accesses to this thread structure.

View File

@ -36,8 +36,9 @@
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stddef.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mman.h>
#ifdef _THREAD_SAFE
#include <machine/reg.h>
@ -45,6 +46,21 @@
#include "pthread_private.h"
#include "libc_private.h"
static u_int64_t next_uniqueid = 1;
#define OFF(f) offsetof(struct pthread, f)
int _thread_next_offset = OFF(tle.tqe_next);
int _thread_uniqueid_offset = OFF(uniqueid);
int _thread_state_offset = OFF(state);
int _thread_name_offset = OFF(name);
int _thread_sig_saved_offset = OFF(sig_saved);
int _thread_saved_sigcontext_offset = OFF(saved_sigcontext);
int _thread_saved_jmp_buf_offset = OFF(saved_jmp_buf);
#undef OFF
int _thread_PS_RUNNING_value = PS_RUNNING;
int _thread_PS_DEAD_value = PS_DEAD;
int
pthread_create(pthread_t * thread, const pthread_attr_t * attr,
void *(*start_routine) (void *), void *arg)
@ -129,11 +145,7 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
else if (mmap(stack,
PTHREAD_STACK_DEFAULT,
PROT_READ | PROT_WRITE,
#ifdef __i386__
MAP_STACK,
#else
MAP_ANON,
#endif
-1, 0) == MAP_FAILED) {
ret = EAGAIN;
munmap(_next_stack,
@ -267,6 +279,12 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
*/
_thread_kern_sig_defer();
/*
* Initialise the unique id which GDB uses to
* track threads.
*/
new_thread->uniqueid = next_uniqueid++;
/*
* Check if the garbage collector thread
* needs to be started.

View File

@ -36,8 +36,9 @@
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stddef.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mman.h>
#ifdef _THREAD_SAFE
#include <machine/reg.h>
@ -45,6 +46,21 @@
#include "pthread_private.h"
#include "libc_private.h"
static u_int64_t next_uniqueid = 1;
#define OFF(f) offsetof(struct pthread, f)
int _thread_next_offset = OFF(tle.tqe_next);
int _thread_uniqueid_offset = OFF(uniqueid);
int _thread_state_offset = OFF(state);
int _thread_name_offset = OFF(name);
int _thread_sig_saved_offset = OFF(sig_saved);
int _thread_saved_sigcontext_offset = OFF(saved_sigcontext);
int _thread_saved_jmp_buf_offset = OFF(saved_jmp_buf);
#undef OFF
int _thread_PS_RUNNING_value = PS_RUNNING;
int _thread_PS_DEAD_value = PS_DEAD;
int
pthread_create(pthread_t * thread, const pthread_attr_t * attr,
void *(*start_routine) (void *), void *arg)
@ -129,11 +145,7 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
else if (mmap(stack,
PTHREAD_STACK_DEFAULT,
PROT_READ | PROT_WRITE,
#ifdef __i386__
MAP_STACK,
#else
MAP_ANON,
#endif
-1, 0) == MAP_FAILED) {
ret = EAGAIN;
munmap(_next_stack,
@ -267,6 +279,12 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
*/
_thread_kern_sig_defer();
/*
* Initialise the unique id which GDB uses to
* track threads.
*/
new_thread->uniqueid = next_uniqueid++;
/*
* Check if the garbage collector thread
* needs to be started.

View File

@ -336,7 +336,8 @@ struct pthread_attr {
*/
#define PTHREAD_STACK_DEFAULT 65536
/* Size of red zone at the end of each stack. */
#define PTHREAD_STACK_GUARD 4096
#define PTHREAD_STACK_GUARD PAGE_SIZE
/*
* Maximum size of initial thread's stack. This perhaps deserves to be larger
* than the stacks of other threads, since many applications are likely to run
@ -466,6 +467,7 @@ struct pthread {
#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115)
u_int32_t magic;
char *name;
u_int64_t uniqueid; /* for gdb */
/*
* Lock for accesses to this thread structure.

View File

@ -36,8 +36,9 @@
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stddef.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mman.h>
#ifdef _THREAD_SAFE
#include <machine/reg.h>
@ -45,6 +46,21 @@
#include "pthread_private.h"
#include "libc_private.h"
static u_int64_t next_uniqueid = 1;
#define OFF(f) offsetof(struct pthread, f)
int _thread_next_offset = OFF(tle.tqe_next);
int _thread_uniqueid_offset = OFF(uniqueid);
int _thread_state_offset = OFF(state);
int _thread_name_offset = OFF(name);
int _thread_sig_saved_offset = OFF(sig_saved);
int _thread_saved_sigcontext_offset = OFF(saved_sigcontext);
int _thread_saved_jmp_buf_offset = OFF(saved_jmp_buf);
#undef OFF
int _thread_PS_RUNNING_value = PS_RUNNING;
int _thread_PS_DEAD_value = PS_DEAD;
int
pthread_create(pthread_t * thread, const pthread_attr_t * attr,
void *(*start_routine) (void *), void *arg)
@ -129,11 +145,7 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
else if (mmap(stack,
PTHREAD_STACK_DEFAULT,
PROT_READ | PROT_WRITE,
#ifdef __i386__
MAP_STACK,
#else
MAP_ANON,
#endif
-1, 0) == MAP_FAILED) {
ret = EAGAIN;
munmap(_next_stack,
@ -267,6 +279,12 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
*/
_thread_kern_sig_defer();
/*
* Initialise the unique id which GDB uses to
* track threads.
*/
new_thread->uniqueid = next_uniqueid++;
/*
* Check if the garbage collector thread
* needs to be started.

View File

@ -336,7 +336,8 @@ struct pthread_attr {
*/
#define PTHREAD_STACK_DEFAULT 65536
/* Size of red zone at the end of each stack. */
#define PTHREAD_STACK_GUARD 4096
#define PTHREAD_STACK_GUARD PAGE_SIZE
/*
* Maximum size of initial thread's stack. This perhaps deserves to be larger
* than the stacks of other threads, since many applications are likely to run
@ -466,6 +467,7 @@ struct pthread {
#define PTHREAD_MAGIC ((u_int32_t) 0xd09ba115)
u_int32_t magic;
char *name;
u_int64_t uniqueid; /* for gdb */
/*
* Lock for accesses to this thread structure.