* [RFA/commit] Add support for DEC threads on alpha-osf
@ 2008-10-07 13:04 Joel Brobecker
2008-10-07 14:08 ` Pedro Alves
2008-10-20 15:50 ` Joel Brobecker
0 siblings, 2 replies; 8+ messages in thread
From: Joel Brobecker @ 2008-10-07 13:04 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2475 bytes --]
Hello,
This is something I implemented a few months ago, and so far, it has
been working well for us. It is based on the OSF pthreaddebug library.
I did the minimal amount of work to be able to switch from thread
to thread. In terms of execution, I just re-route the target queries
down to the lower layer.
Pedro, is there something I should be doing for the always-a-thread
thing? I tested with a program that doesn't use threads, and the
good news is that I do see a "process" thread. Perhaps that was
thanks to you. On the other hand, I still see that process thread
when debugging programs that use threads, and I wonder if this is
a problem or not.
Before my patch, the output looked like:
(gdb) info threads
4 LWP 3 task_switch.break_me () at task_switch.adb:43
3 LWP 9 0x0000000000000000 in ?? ()
2 LWP 8 0x00000300000408e8 in __nxm_thread_block ()
from /usr/shlib/libpthread.so
* 1 process 256360 task_switch.break_me () at task_switch.adb:43
(the LWPs come from procfs but they don't relate to user-level threads;
notice how LWP 3 is the same as process 256360)
After the patch, the real threads now start appearing:
(gdb) info threads
7 LWP 3 task_switch.break_me () at task_switch.adb:43
6 LWP 9 0x0000000000000000 in ?? ()
5 LWP 8 0x00000300000408e8 in __nxm_thread_block ()
from /usr/shlib/libpthread.so
* 4 Thread 3 task_switch.break_me () at task_switch.adb:43
3 Thread 2 0x000003000004067c in __hstTransferRegistersPC ()
from /usr/shlib/libpthread.so
2 Thread 1 0x000003000004067c in __hstTransferRegistersPC ()
from /usr/shlib/libpthread.so
1 process 269190 task_switch.break_me () at task_switch.adb:43
(notice how now we have 3 thread entries that seem to be the same
actual thread)
Personally, I think it's fine.
2008-10-07 Joel Brobecker <brobecker@adacore.com>
* dec-thread.c: New file.
* config/alpha/alpha-osf3.mh (NATDEPFILES): Add dec-thread.o.
(NAT_CLIBS): Define.
I'd like to commit in a week, if there are no objections. In terms
of testing, I tried running the testsuite again, but one more time
I failed miserably. I had hoped that the fixes to the terminal issues
might have explained the timeouts, but to no avail. So I can only
offer the fact that this code has been tested through AdaCore's
testsuite and passed all tests, including our tests involving tasking.
Any objection?
--
Joel
[-- Attachment #2: dec-thread.c --]
[-- Type: text/plain, Size: 17537 bytes --]
/* Copyright (C) 2008 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "command.h"
#include "gdbcmd.h"
#include "target.h"
#include "observer.h"
#include <sys/procfs.h>
#include "gregset.h"
#include "regcache.h"
#include "inferior.h"
#include "gdbthread.h"
#include <pthread_debug.h>
/* Print debugging traces if set to non-zero. */
static int debug_dec_thread = 0;
/* Non-zero if the dec-thread layer is active. */
static int dec_thread_active = 0;
/* The pthread_debug context. */
pthreadDebugContext_t debug_context;
/* The dec-thread target_ops structure. */
static struct target_ops dec_thread_ops;
/* A copy of the target_ops over which our dec_thread_ops is pushed. */
static struct target_ops base_target;
/* Print a debug trace if DEBUG_DEC_THREAD is set (its value is adjusted
by the user using "set debug dec-thread ..."). */
static void
debug (char *format, ...)
{
if (debug_dec_thread)
{
va_list args;
va_start (args, format);
printf_unfiltered ("DEC Threads: ");
vprintf_unfiltered (format, args);
printf_unfiltered ("\n");
va_end (args);
}
}
/* pthread debug callbacks. */
static int
suspend_clbk (void *caller_context)
{
return ESUCCESS;
}
static int
resume_clbk (void *caller_context)
{
return ESUCCESS;
}
static int
hold_clbk (void *caller_context, pthreadDebugKId_t kernel_tid)
{
return ESUCCESS;
}
static int
unhold_clbk (void *caller_context, pthreadDebugKId_t kernel_tid)
{
return ESUCCESS;
}
static int
read_clbk (void *caller_context, void *address, void *buffer,
unsigned long size)
{
int status = target_read_memory ((CORE_ADDR) address, buffer, size);
if (status != 0)
return EINVAL;
return ESUCCESS;
}
static int
write_clbk (void *caller_context, void *address, void *buffer,
unsigned long size)
{
int status = target_write_memory ((CORE_ADDR) address, buffer, size);
if (status != 0)
return EINVAL;
return ESUCCESS;
}
/* Get integer regs */
static int
get_reg_clbk(void *caller_context, pthreadDebugGetRegRtn_t regs,
pthreadDebugKId_t kernel_tid)
{
debug ("get_reg_clbk");
/* Not sure that we actually need to do anything in this callback. */
return ESUCCESS;
}
/* Set integer regs */
static int
set_reg_clbk(void *caller_context, const pthreadDebugRegs_t *regs,
pthreadDebugKId_t kernel_tid)
{
debug ("set_reg_clbk");
/* Not sure that we actually need to do anything in this callback. */
return ESUCCESS;
}
static int
output_clbk (void *caller_context, char *line)
{
printf_filtered ("%s\n", line);
return ESUCCESS;
}
static int
error_clbk (void *caller_context, char *line)
{
fprintf_filtered (gdb_stderr, "%s\n", line);
return ESUCCESS;
}
/* Get floating-point regs. */
static int
get_fpreg_clbk (void *caller_context, pthreadDebugFregs_p fregs,
pthreadDebugKId_t kernel_tid)
{
debug ("get_fpreg_clbk");
/* Not sure that we actually need to do anything in this callback. */
return ESUCCESS;
}
/* Set floating-point regs. */
static int
set_fpreg_clbk (void *caller_context, const pthreadDebugFregs_t *fregs,
pthreadDebugKId_t kernel_tid)
{
debug ("set_fpreg_clbk");
/* Not sure that we actually need to do anything in this callback. */
return ESUCCESS;
}
static void *
malloc_clbk (void *caller_context, size_t size)
{
return xmalloc (size);
}
static void
free_clbk (void *caller_context, void *address)
{
xfree (address);
}
static int
kthdinfo_clbk (pthreadDebugClient_t caller_context,
pthreadDebugKId_t kernel_tid,
pthreadDebugKThreadInfo_p thread_info)
{
return ENOTSUP;
}
static int
speckthd_clbk (pthreadDebugClient_t caller_context,
pthreadDebugSpecialType_t type,
pthreadDebugKId_t *kernel_tid)
{
return ENOTSUP;
}
static pthreadDebugCallbacks_t debug_callbacks =
{
PTHREAD_DEBUG_VERSION,
(pthreadDebugGetMemRtn_t) read_clbk,
(pthreadDebugSetMemRtn_t) write_clbk,
suspend_clbk,
resume_clbk,
kthdinfo_clbk,
hold_clbk,
unhold_clbk,
(pthreadDebugGetFregRtn_t) get_fpreg_clbk,
(pthreadDebugSetFregRtn_t) set_fpreg_clbk,
(pthreadDebugGetRegRtn_t) get_reg_clbk,
(pthreadDebugSetRegRtn_t) set_reg_clbk,
(pthreadDebugOutputRtn_t) output_clbk,
(pthreadDebugOutputRtn_t) error_clbk,
malloc_clbk,
free_clbk,
speckthd_clbk
};
/* Activate thread support if appropriate. Do nothing if thread
support is already active. */
static void
enable_dec_thread (void)
{
struct minimal_symbol *msym;
void* caller_context;
int status;
/* If already active, nothing more to do. */
if (dec_thread_active)
return;
msym = lookup_minimal_symbol ("__pthread_dbg_symtable", NULL, NULL);
if (msym == NULL)
{
debug ("enable_dec_thread: No __pthread_dbg_symtable");
return;
}
status = pthreadDebugContextInit (&caller_context, &debug_callbacks,
(void *) SYMBOL_VALUE_ADDRESS (msym),
&debug_context);
if (status != ESUCCESS)
{
debug ("enable_dec_thread: pthreadDebugContextInit -> %d",
status);
return;
}
base_target = current_target;
push_target (&dec_thread_ops);
dec_thread_active = 1;
debug ("enable_dec_thread: Thread support enabled.");
}
/* Deactivate thread support. Do nothing is thread support is
already inactive. */
static void
disable_dec_thread (void)
{
if (!dec_thread_active)
return;
pthreadDebugContextDestroy (debug_context);
unpush_target (&dec_thread_ops);
dec_thread_active = 0;
}
/* A structure that contains a thread ID and is associated
pthreadDebugThreadInfo_t data. */
struct dec_thread_info
{
pthreadDebugId_t thread;
pthreadDebugThreadInfo_t info;
};
typedef struct dec_thread_info dec_thread_info_s;
/* The list of user threads. */
DEF_VEC_O (dec_thread_info_s);
VEC(dec_thread_info_s) *dec_thread_list;
/* Release the memory used by the given VECP thread list pointer.
Then set *VECP to NULL. */
static void
free_dec_thread_info_vec (VEC(dec_thread_info_s) **vecp)
{
int i;
struct dec_thread_info *item;
VEC(dec_thread_info_s) *vec = *vecp;
for (i = 0; VEC_iterate (dec_thread_info_s, vec, i, item); i++)
xfree (item);
VEC_free (dec_thread_info_s, vec);
*vecp = NULL;
}
/* Return a thread's ptid given its associated INFO. */
static ptid_t
ptid_build_from_info (struct dec_thread_info info)
{
int pid = ptid_get_pid (inferior_ptid);
return ptid_build (pid, 0, (long) info.thread);
}
/* Recompute the list of user threads and store the result in
DEC_THREAD_LIST. */
static void
update_dec_thread_list (void)
{
pthreadDebugId_t thread;
pthreadDebugThreadInfo_t info;
int res;
free_dec_thread_info_vec (&dec_thread_list);
res = pthreadDebugThdSeqInit (debug_context, &thread);
while (res == ESUCCESS)
{
res = pthreadDebugThdGetInfo (debug_context, thread, &info);
if (res != ESUCCESS)
warning (_("unable to get thread info, ignoring thread %ld"),
thread);
else if (info.kind == PTHREAD_DEBUG_THD_KIND_INITIAL
|| info.kind == PTHREAD_DEBUG_THD_KIND_NORMAL)
{
struct dec_thread_info *item =
xmalloc (sizeof (struct dec_thread_info));
item->thread = thread;
item->info = info;
VEC_safe_push (dec_thread_info_s, dec_thread_list, item);
}
res = pthreadDebugThdSeqNext (debug_context, &thread);
}
pthreadDebugThdSeqDestroy (debug_context);
}
/* A callback to count the number of threads known to GDB. */
static int
dec_thread_count_gdb_threads (struct thread_info *ignored, void *context)
{
int *count = (int *) context;
*count++;
return 0;
}
/* A callback that saves the given thread INFO at the end of an
array. The end of the array is given in the CONTEXT and is
incremented once the info has been added. */
static int
dec_thread_add_gdb_thread (struct thread_info *info, void *context)
{
struct thread_info ***listp = (struct thread_info ***) context;
**listp = info;
*listp++;
return 0;
}
/* Resynchronize the list of threads known by GDB with the actual
list of threads reported by libpthread_debug. */
static void
resync_thread_list (void)
{
int i;
struct dec_thread_info *info;
int num_gdb_threads = 0;
struct thread_info **gdb_thread_list;
struct thread_info **next_thread_info;
update_dec_thread_list ();
/* Add new threads. */
for (i = 0; VEC_iterate (dec_thread_info_s, dec_thread_list, i, info);
i++)
{
ptid_t ptid = ptid_build_from_info (*info);
if (!in_thread_list (ptid))
add_thread (ptid);
}
/* Remove threads that no longer exist. To help with the search,
we build an array of GDB threads, and then iterate over this
array. */
iterate_over_threads (dec_thread_count_gdb_threads,
(void *) &num_gdb_threads);
gdb_thread_list = alloca (num_gdb_threads * sizeof (struct thread_info *));
next_thread_info = gdb_thread_list;
iterate_over_threads (dec_thread_add_gdb_thread, (void *) &next_thread_info);
for (i = 0; i < num_gdb_threads; i++)
{
int j;
for (j = 0; VEC_iterate (dec_thread_info_s, dec_thread_list, j, info);
j++)
if (ptid_equal (gdb_thread_list[i]->ptid,
ptid_build_from_info (*info)))
break;
delete_thread (gdb_thread_list[i]->ptid);
}
}
/* The "to_detach" method of the dec_thread_ops. */
static void
dec_thread_detach (char *args, int from_tty)
{
debug ("dec_thread_detach");
disable_dec_thread ();
base_target.to_detach (args, from_tty);
}
/* Return the ptid of the thread that is currently active. */
static ptid_t
get_active_ptid (void)
{
int i;
struct dec_thread_info *info;
for (i = 0; VEC_iterate (dec_thread_info_s, dec_thread_list, i, info);
i++)
if (info->info.state == PTHREAD_DEBUG_STATE_RUNNING)
return ptid_build_from_info (*info);
/* No active thread found. This can happen when the program
has just exited. */
return null_ptid;
}
/* The "to_wait" method of the dec_thread_ops. */
static ptid_t
dec_thread_wait (ptid_t ptid, struct target_waitstatus *status)
{
ptid_t active_ptid;
debug ("dec_thread_wait");
ptid = base_target.to_wait (ptid, status);
/* The ptid returned by the base_target is the ptid of the process.
We need to find which thread is currently active and return its
ptid. */
resync_thread_list ();
active_ptid = get_active_ptid ();
if (ptid_equal (active_ptid, null_ptid))
return ptid;
return active_ptid;
}
/* Fetch the general purpose and floating point registers for the given
thread TID, and store the result in GREGSET and FPREGSET. Return
zero if successful. */
static int
dec_thread_get_regsets (pthreadDebugId_t tid, gdb_gregset_t *gregset,
gdb_fpregset_t *fpregset)
{
int res;
pthreadDebugRegs_t regs;
pthreadDebugFregs_t fregs;
res = pthreadDebugThdGetReg (debug_context, tid, ®s);
if (res != ESUCCESS)
{
debug ("dec_thread_fetch_registers: pthreadDebugThdGetReg -> %d", res);
return -1;
}
memcpy (gregset->regs, ®s, sizeof (regs));
res = pthreadDebugThdGetFreg (debug_context, tid, &fregs);
if (res != ESUCCESS)
{
debug ("dec_thread_fetch_registers: pthreadDebugThdGetFreg -> %d", res);
return -1;
}
memcpy (fpregset->regs, &fregs, sizeof (fregs));
return 0;
}
/* The "to_fetch_registers" method of the dec_thread_ops.
Because the dec-thread debug API doesn't allow us to fetch
only one register, we simply ignore regno and fetch+supply all
registers. */
static void
dec_thread_fetch_registers (struct regcache *regcache, int regno)
{
pthreadDebugId_t tid = ptid_get_tid (inferior_ptid);
gregset_t gregset;
fpregset_t fpregset;
int res;
debug ("dec_thread_fetch_registers (tid=%ld, regno=%d)", tid, regno);
if (tid == 0 || ptid_equal (inferior_ptid, get_active_ptid ()))
{
base_target.to_fetch_registers (regcache, regno);
return;
}
res = dec_thread_get_regsets (tid, &gregset, &fpregset);
if (res != 0)
return;
supply_gregset (regcache, &gregset);
supply_fpregset (regcache, &fpregset);
}
/* Store the registers given in GREGSET and FPREGSET into the associated
general purpose and floating point registers of thread TID. Return
zero if successful. */
static int
dec_thread_set_regsets (pthreadDebugId_t tid, gdb_gregset_t gregset,
gdb_fpregset_t fpregset)
{
int res;
pthreadDebugRegs_t regs;
pthreadDebugFregs_t fregs;
memcpy (®s, gregset.regs, sizeof (regs));
res = pthreadDebugThdSetReg (debug_context, tid, ®s);
if (res != ESUCCESS)
{
debug ("dec_thread_fetch_registers: pthreadDebugThdSetReg -> %d", res);
return -1;
}
memcpy (&fregs, fpregset.regs, sizeof (fregs));
res = pthreadDebugThdSetFreg (debug_context, tid, &fregs);
if (res != ESUCCESS)
{
debug ("dec_thread_fetch_registers: pthreadDebugThdSetFreg -> %d", res);
return -1;
}
return 0;
}
/* The "to_store_registers" method of the dec_thread_ops.
Because the dec-thread debug API doesn't allow us to store
just one register, we store all the registers. */
static void
dec_thread_store_registers (struct regcache *regcache, int regno)
{
pthreadDebugId_t tid = ptid_get_tid (inferior_ptid);
gregset_t gregset;
fpregset_t fpregset;
int res;
debug ("dec_thread_store_registers (tid=%ld, regno=%d)", tid, regno);
if (tid == 0 || ptid_equal (inferior_ptid, get_active_ptid ()))
{
base_target.to_store_registers (regcache, regno);
return;
}
/* FIXME: brobecker/2008-05-28: I wonder if we could simply check
in which register set the register is and then only store the
registers for that register set, instead of storing both register
sets. */
fill_gregset (regcache, &gregset, -1);
fill_fpregset (regcache, &fpregset, -1);
res = dec_thread_set_regsets (tid, gregset, fpregset);
if (res != 0)
warning (_("failed to store registers."));
}
/* The "to_mourn_inferior" method of the dec_thread_ops. */
static void
dec_thread_mourn_inferior (void)
{
debug ("dec_thread_mourn_inferior");
disable_dec_thread ();
base_target.to_mourn_inferior ();
}
/* The "to_thread_alive" method of the dec_thread_ops. */
static int
dec_thread_thread_alive (ptid_t ptid)
{
debug ("dec_thread_thread_alive (tid=%ld)", ptid_get_tid (ptid));
/* The thread list maintained by GDB is up to date, since we update
it everytime we stop. So check this list. */
return in_thread_list (ptid);
}
/* The "to_pid_to_str" method of the dec_thread_ops. */
static char *
dec_thread_pid_to_str (ptid_t ptid)
{
static char *ret = NULL;
if (ptid_get_tid (ptid) == 0)
return base_target.to_pid_to_str (ptid);
/* Free previous return value; a new one will be allocated by
xstrprintf(). */
xfree (ret);
ret = xstrprintf (_("Thread %ld"), ptid_get_tid (ptid));
return ret;
}
/* A "new-objfile" observer. Used to activate/deactivate dec-thread
support. */
static void
dec_thread_new_objfile_observer (struct objfile *objfile)
{
if (objfile != NULL)
enable_dec_thread ();
else
disable_dec_thread ();
}
static void
init_dec_thread_ops (void)
{
dec_thread_ops.to_shortname = "dec-threads";
dec_thread_ops.to_longname = _("DEC threads support");
dec_thread_ops.to_doc = _("DEC threads support");
dec_thread_ops.to_detach = dec_thread_detach;
dec_thread_ops.to_wait = dec_thread_wait;
dec_thread_ops.to_fetch_registers = dec_thread_fetch_registers;
dec_thread_ops.to_store_registers = dec_thread_store_registers;
dec_thread_ops.to_mourn_inferior = dec_thread_mourn_inferior;
dec_thread_ops.to_thread_alive = dec_thread_thread_alive;
dec_thread_ops.to_pid_to_str = dec_thread_pid_to_str;
dec_thread_ops.to_stratum = thread_stratum;
dec_thread_ops.to_magic = OPS_MAGIC;
}
void
_initialize_dec_thread (void)
{
init_dec_thread_ops ();
add_target (&dec_thread_ops);
observer_attach_new_objfile (dec_thread_new_objfile_observer);
add_setshow_boolean_cmd ("dec-thread", class_maintenance, &debug_dec_thread,
_("Set debugging of DEC threads module."),
_("Show debugging of DEC threads module."),
_("Enables debugging output (used to debug GDB)."),
NULL, NULL,
&setdebuglist, &showdebuglist);
}
[-- Attachment #3: dec-threads.diff --]
[-- Type: text/plain, Size: 556 bytes --]
Index: config/alpha/alpha-osf3.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/alpha/alpha-osf3.mh,v
retrieving revision 1.7
diff -u -p -r1.7 alpha-osf3.mh
--- config/alpha/alpha-osf3.mh 6 May 2007 23:04:26 -0000 1.7
+++ config/alpha/alpha-osf3.mh 7 Oct 2008 12:43:08 -0000
@@ -2,4 +2,5 @@
NAT_FILE= nm-osf3.h
NATDEPFILES= corelow.o alpha-nat.o fork-child.o \
solib-osf.o solib.o procfs.o proc-api.o proc-events.o proc-flags.o \
- proc-why.o
+ proc-why.o dec-thread.o
+NAT_CLIBS= -lpthreaddebug
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFA/commit] Add support for DEC threads on alpha-osf
2008-10-07 13:04 [RFA/commit] Add support for DEC threads on alpha-osf Joel Brobecker
@ 2008-10-07 14:08 ` Pedro Alves
2008-10-07 15:02 ` Joel Brobecker
2008-10-20 15:50 ` Joel Brobecker
1 sibling, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2008-10-07 14:08 UTC (permalink / raw)
To: gdb-patches; +Cc: Joel Brobecker
On Tuesday 07 October 2008 14:03:22, Joel Brobecker wrote:
> Pedro, is there something I should be doing for the always-a-thread
> thing?
Hmmm, procfs.c. It looks weird that LWP 3 and the main process are
the same thing. If they are the same, and I haven't messed something up,
you should only see one of them. IIRC, I don't get that on solaris.
> I tested with a program that doesn't use threads, and the
> good news is that I do see a "process" thread. Perhaps that was
> thanks to you.
If there are no other LWPs, then yes, I made that change. Before my
changes, if there were other LWPs in the process, then you'd've
already see the "process" thread, as it was added to the thread list
as soon as we would detect a new LWP. After my changes, you get
that "process" even if there are no other LWPs other than the
main process in the inferior.
> On the other hand, I still see that process thread
> when debugging programs that use threads, and I wonder if this is
> a problem or not.
So, from this info threads output:
> After the patch, the real threads now start appearing:
>
> (gdb) info threads
> 7 LWP 3 task_switch.break_me () at task_switch.adb:43
> 6 LWP 9 0x0000000000000000 in ?? ()
> 5 LWP 8 0x00000300000408e8 in __nxm_thread_block ()
> from /usr/shlib/libpthread.so
> * 4 Thread 3 task_switch.break_me () at task_switch.adb:43
> 3 Thread 2 0x000003000004067c in __hstTransferRegistersPC ()
> from /usr/shlib/libpthread.so
> 2 Thread 1 0x000003000004067c in __hstTransferRegistersPC ()
> from /usr/shlib/libpthread.so
> 1 process 269190 task_switch.break_me () at task_switch.adb:43
... this is an M:N configuration? It looks like it, because threads 2,3,4 were
added before the lwps 5,6,7, and the threads 2,3 show a different
frame from lwps 5,6. In that case, it seems fine to me to show them,
assuming the user stepping an LWP doesn't make GDB do something
dump regarding GDB's stepping state of the user threads.
Or, are all user threads scheduled on the main process/lwp ? Then what
the heck is thread 5 blocked on ? :-)
Or, if this is user threads/LWPs are 1:1 then something looks broken. If
that's the case, my opinion would be that it would be best to only
show the user threads.
Anyway, these are all dumb question that came to mind, because
I miss a description of DEC's thread model at the top of
dec-thread.c. Something akin to sol-thread.c, but needn't
be so extensive. :-)
--
Pedro Alves
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Add support for DEC threads on alpha-osf
2008-10-07 14:08 ` Pedro Alves
@ 2008-10-07 15:02 ` Joel Brobecker
2008-10-07 15:19 ` Pedro Alves
2008-10-07 15:21 ` Nathan Froyd
0 siblings, 2 replies; 8+ messages in thread
From: Joel Brobecker @ 2008-10-07 15:02 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
Thanks for the quick feedback!
> Hmmm, procfs.c. It looks weird that LWP 3 and the main process are
> the same thing. If they are the same, and I haven't messed something up,
> you should only see one of them. IIRC, I don't get that on solaris.
How does it work (to determine whether the process and the LWP are
the same)? I could probably take a look. Not sure whether I could
help much, though.
> ... this is an M:N configuration? It looks like it, because threads
> 2,3,4 were added before the lwps 5,6,7, and the threads 2,3 show a
> different frame from lwps 5,6.
I am strongly suspecting that it is indeed an M:N configuration,
but I don't know that for sure. The LWPs look like kernel threads
(the pthreaddebug API mentions their existence).
> Or, are all user threads scheduled on the main process/lwp ? Then what
> the heck is thread 5 blocked on ? :-)
Very simple: I don't know :). The threads library is a black box
to me. Any other question?
> Anyway, these are all dumb question that came to mind, because
> I miss a description of DEC's thread model at the top of
> dec-thread.c. Something akin to sol-thread.c, but needn't
> be so extensive. :-)
Yes, I miss this description too :). I searched all the headers
as well as the web, and didn't find anything useful. So, my
conclusion at this point is that we can only go with the suspicion
that it is indeed and M:N model. There might be a bug (process
thread should not show up if identical to one of the LWPs),
but this is separate from my patch. I don't mind having a quick
look if it's not too time-consuming. What do you think?
--
Joel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Add support for DEC threads on alpha-osf
2008-10-07 15:02 ` Joel Brobecker
@ 2008-10-07 15:19 ` Pedro Alves
2008-10-07 15:24 ` Joel Brobecker
2008-10-07 15:21 ` Nathan Froyd
1 sibling, 1 reply; 8+ messages in thread
From: Pedro Alves @ 2008-10-07 15:19 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On Tuesday 07 October 2008 16:01:54, Joel Brobecker wrote:
> Thanks for the quick feedback!
>
> > Hmmm, procfs.c. It looks weird that LWP 3 and the main process are
> > the same thing. If they are the same, and I haven't messed something up,
> > you should only see one of them. IIRC, I don't get that on solaris.
>
> How does it work (to determine whether the process and the LWP are
> the same)? I could probably take a look. Not sure whether I could
> help much, though.
Maybe here:
procfs_init_inferior:
...
/* We now have have access to the lwpid of the main thread/lwp. */
lwpid = proc_get_current_thread (pi);
/* Create a procinfo for the main lwp. */
create_procinfo (pid, lwpid);
/* We already have a main thread registered in the thread table at
this point, but it didn't have any lwp info yet. Notify the core
about it. This changes inferior_ptid as well. */
thread_change_ptid (pid_to_ptid (pid),
MERGEPID (pid, lwpid));
... maybe proc_get_current_thread returns 0, and then later on in
procfs_wait we're adding the main thread again, but then with an
lwp id already. But what sounded very strange is that the LWP is
number 3, not 1.
> I don't mind having a quick
> look if it's not too time-consuming. What do you think?
It's certainly fine the way it is to me, just an annoyance. I'm happy
to find out that we don't crash in this situation, so thanks
for that. :-)
--
Pedro Alves
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFA/commit] Add support for DEC threads on alpha-osf
2008-10-07 15:19 ` Pedro Alves
@ 2008-10-07 15:24 ` Joel Brobecker
2008-10-07 16:36 ` Pedro Alves
0 siblings, 1 reply; 8+ messages in thread
From: Joel Brobecker @ 2008-10-07 15:24 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
> ... maybe proc_get_current_thread returns 0, and then later on in
> procfs_wait we're adding the main thread again, but then with an
> lwp id already. But what sounded very strange is that the LWP is
> number 3, not 1.
I need to look further into this, but would it help explain things
if I said that the LWPs are added when I do "info threads", not when
the process stops?
> It's certainly fine the way it is to me, just an annoyance. I'm happy
> to find out that we don't crash in this situation, so thanks
> for that. :-)
You're welcome. I will be sure to look for you if I do manage to
crash the debugger ;-).
--
Joel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Add support for DEC threads on alpha-osf
2008-10-07 15:24 ` Joel Brobecker
@ 2008-10-07 16:36 ` Pedro Alves
0 siblings, 0 replies; 8+ messages in thread
From: Pedro Alves @ 2008-10-07 16:36 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On Tuesday 07 October 2008 16:23:35, Joel Brobecker wrote:
> > ... maybe proc_get_current_thread returns 0, and then later on in
> > procfs_wait we're adding the main thread again, but then with an
> > lwp id already. But what sounded very strange is that the LWP is
> > number 3, not 1.
>
> I need to look further into this, but would it help explain things
> if I said that the LWPs are added when I do "info threads", not when
> the process stops?
Possibly maybe. Dunno, perhaps LWP ids 1 and 2 are gone when we go
through the shell doing fork/execs while doing the fork-child dance.
--
Pedro Alves
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Add support for DEC threads on alpha-osf
2008-10-07 15:02 ` Joel Brobecker
2008-10-07 15:19 ` Pedro Alves
@ 2008-10-07 15:21 ` Nathan Froyd
1 sibling, 0 replies; 8+ messages in thread
From: Nathan Froyd @ 2008-10-07 15:21 UTC (permalink / raw)
To: Joel Brobecker; +Cc: Pedro Alves, gdb-patches
On Tue, Oct 07, 2008 at 11:01:54AM -0400, Joel Brobecker wrote:
> > ... this is an M:N configuration? It looks like it, because threads
> > 2,3,4 were added before the lwps 5,6,7, and the threads 2,3 show a
> > different frame from lwps 5,6.
>
> I am strongly suspecting that it is indeed an M:N configuration,
> but I don't know that for sure. The LWPs look like kernel threads
> (the pthreaddebug API mentions their existence).
Yes, OSF/1 uses an M:N configuration. (From hard-won debugging
experience and http://members.aol.com/drbutenhof/ThreadTable.html.)
-Nathan
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFA/commit] Add support for DEC threads on alpha-osf
2008-10-07 13:04 [RFA/commit] Add support for DEC threads on alpha-osf Joel Brobecker
2008-10-07 14:08 ` Pedro Alves
@ 2008-10-20 15:50 ` Joel Brobecker
1 sibling, 0 replies; 8+ messages in thread
From: Joel Brobecker @ 2008-10-20 15:50 UTC (permalink / raw)
To: gdb-patches
> 2008-10-07 Joel Brobecker <brobecker@adacore.com>
>
> * dec-thread.c: New file.
> * config/alpha/alpha-osf3.mh (NATDEPFILES): Add dec-thread.o.
> (NAT_CLIBS): Define.
I checked this patch in. NEWS update coming shortly...
--
Joel
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-10-20 15:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-07 13:04 [RFA/commit] Add support for DEC threads on alpha-osf Joel Brobecker
2008-10-07 14:08 ` Pedro Alves
2008-10-07 15:02 ` Joel Brobecker
2008-10-07 15:19 ` Pedro Alves
2008-10-07 15:24 ` Joel Brobecker
2008-10-07 16:36 ` Pedro Alves
2008-10-07 15:21 ` Nathan Froyd
2008-10-20 15:50 ` Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox