Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/external/gpl3/gdb/dist/gdb Pull up following revision(s) ...
details: https://anonhg.NetBSD.org/src/rev/44735b4ebf19
branches: netbsd-6
changeset: 774037:44735b4ebf19
user: riz <riz%NetBSD.org@localhost>
date: Tue Apr 24 19:38:35 2012 +0000
description:
Pull up following revision(s) (requested by skrll in ticket #198):
external/gpl3/gdb/dist/gdb/nbsd-thread.c 1.10-1.16
external/gpl3/gdb/dist/gdb/inf-ptrace.c 1.5
Fix gdb debugging of threaded programs.
[skrll, ticket #198]
diffstat:
external/gpl3/gdb/dist/gdb/inf-ptrace.c | 4 +
external/gpl3/gdb/dist/gdb/nbsd-thread.c | 468 +------------------------------
2 files changed, 16 insertions(+), 456 deletions(-)
diffs (truncated from 605 to 300 lines):
diff -r c5d84defee93 -r 44735b4ebf19 external/gpl3/gdb/dist/gdb/inf-ptrace.c
--- a/external/gpl3/gdb/dist/gdb/inf-ptrace.c Mon Apr 23 23:41:47 2012 +0000
+++ b/external/gpl3/gdb/dist/gdb/inf-ptrace.c Tue Apr 24 19:38:35 2012 +0000
@@ -366,7 +366,11 @@
all possible successor instructions), so we don't have to
worry about that here. */
request = PT_STEP;
+#ifdef __NetBSD__
+ sig = ptid_get_lwp(ptid);
+#else
sig = 0;
+#endif
} else
sig = target_signal_to_host (signal);
diff -r c5d84defee93 -r 44735b4ebf19 external/gpl3/gdb/dist/gdb/nbsd-thread.c
--- a/external/gpl3/gdb/dist/gdb/nbsd-thread.c Mon Apr 23 23:41:47 2012 +0000
+++ b/external/gpl3/gdb/dist/gdb/nbsd-thread.c Tue Apr 24 19:38:35 2012 +0000
@@ -85,13 +85,10 @@
#define GET_PID(ptid) ptid_get_pid (ptid)
#define GET_LWP(ptid) ptid_get_lwp (ptid)
-#define GET_THREAD(ptid) ptid_get_tid (ptid)
#define IS_LWP(ptid) (GET_LWP (ptid) != 0)
-#define IS_THREAD(ptid) (GET_THREAD (ptid) != 0)
-#define BUILD_LWP(lwp, ptid) ptid_build (GET_PID(ptid), lwp, 0)
-#define BUILD_THREAD(tid, ptid) ptid_build (GET_PID(ptid), 0, tid)
+#define BUILD_LWP(lwp, ptid) ptid_build (GET_PID(ptid), (lwp), 0)
static td_proc_t *main_ta;
@@ -146,6 +143,7 @@
nbsd_thread_active = 1;
main_ptid = inferior_ptid;
cached_thread = minus_one_ptid;
+ thread_change_ptid(inferior_ptid, BUILD_LWP(1, inferior_ptid));
nbsd_find_new_threads (NULL);
inferior_ptid = find_active_thread ();
}
@@ -227,39 +225,6 @@
if (td_thr_info (th, &ti) != 0)
return -1;
- if ((ti.thread_id != GET_THREAD (*pt)) &&
- (ti.thread_type == TD_TYPE_USER) &&
- (ti.thread_state != TD_STATE_SUSPENDED) &&
- (ti.thread_state != TD_STATE_ZOMBIE))
- {
- val = td_thr_suspend(th);
- if (val != 0)
- error ("thread_resume_suspend_cb: td_thr_suspend(%p): %s", th,
- td_err_string (val));
-
- if (nsusp == nsuspalloc)
- {
- if (nsuspalloc == 0)
- {
- nsuspalloc = 32;
- susp = malloc (nsuspalloc * sizeof(td_thread_t *));
- if (susp == NULL)
- error ("thread_resume_suspend_cb: out of memory\n");
- }
- else
- {
- static td_thread_t **newsusp;
- nsuspalloc *= 2;
- newsusp = realloc (susp, nsuspalloc * sizeof(td_thread_t *));
- if (newsusp == NULL)
- error ("thread_resume_suspend_cb: out of memory\n");
- susp = newsusp;
- }
- }
- susp[nsusp] = th;
- nsusp++;
- }
-
return 0;
}
@@ -276,20 +241,9 @@
isn't anything we can do but pass it down to the ptrace call;
given the flexibility of the LWP-to-thread mapping, this might or
might not accomplish what the user wanted. */
- if (GET_PID (ptid) != -1 && IS_THREAD (ptid))
- {
- int val;
-
- val = td_thr_iter (main_ta, thread_resume_suspend_cb, &ptid);
- if (val != 0)
- error ("nbsd_thread_resume td_thr_iter: %s", td_err_string (val));
-
- beneath->to_resume (beneath, ptid, step, signo);
-
- /* can't un-suspend just yet, child may not be stopped */
- }
- else
- beneath->to_resume (beneath, ptid, step, signo);
+ if (ptid_get_pid(ptid) == -1)
+ ptid = inferior_ptid;
+ beneath->to_resume (beneath, ptid, step, signo);
cached_thread = minus_one_ptid;
}
@@ -380,29 +334,12 @@
old_chain = save_inferior_ptid ();
- if (nbsd_thread_active && IS_THREAD (inferior_ptid))
+ if (!target_has_execution)
{
- if ((val = td_map_id2thr (main_ta, GET_THREAD (inferior_ptid), &thread)) != 0)
- error ("nbsd_thread_fetch_registers: td_map_id2thr: %s\n",
- td_err_string (val));
- if ((val = td_thr_getregs (thread, 0, &gregs)) != 0)
- error ("nbsd_thread_fetch_registers: td_thr_getregs: %s\n",
- td_err_string (val));
- supply_gregset (cache, &gregs);
-#ifdef HAVE_FPREGS
- if ((val = td_thr_getregs (thread, 1, &fpregs)) == 0)
- supply_fpregset (cache, &fpregs);
-#endif
+ inferior_ptid = pid_to_ptid ((GET_LWP (inferior_ptid) << 16) |
+ GET_PID (inferior_ptid));
}
- else
- {
- if (!target_has_execution)
- {
- inferior_ptid = pid_to_ptid ((GET_LWP (inferior_ptid) << 16) |
- GET_PID (inferior_ptid));
- }
- beneath->to_fetch_registers (beneath, cache, regno);
- }
+ beneath->to_fetch_registers (beneath, cache, regno);
do_cleanups (old_chain);
}
@@ -419,34 +356,7 @@
#endif
int val;
- if (nbsd_thread_active && IS_THREAD (inferior_ptid))
- {
- val = td_map_id2thr (main_ta, GET_THREAD (inferior_ptid), &thread);
- if (val != 0)
- error ("nbsd_thread_store_registers: td_map_id2thr: %s\n",
- td_err_string (val));
-
- fill_gregset (cache, &gregs, -1);
-#ifdef HAVE_FPREGS
- fill_fpregset (cache, &fpregs, -1);
-#endif
-
- val = td_thr_setregs (thread, 0, &gregs);
- if (val != 0)
- error ("nbsd_thread_store_registers: td_thr_setregs: %s\n",
- td_err_string (val));
-#ifdef HAVE_FPREGS
- val = td_thr_setregs (thread, 1, &fpregs);
- if (val != 0)
- error ("nbsd_thread_store_registers: td_thr_setregs: %s\n",
- td_err_string (val));
-#endif
- }
- else
- {
- beneath->to_store_registers (beneath, cache, regno);
- }
-
+ beneath->to_store_registers (beneath, cache, regno);
}
@@ -503,18 +413,9 @@
td_thread_t *th;
char name[32];
- if ((GET_THREAD(ptid) == 0) &&
- (GET_LWP(ptid) == 0) &&
+ if ((GET_LWP(ptid) == 0) &&
(nbsd_thread_active == 0))
sprintf (buf, "process %d", GET_PID (ptid));
- else if (IS_THREAD (ptid))
- {
- if ((td_map_id2thr (main_ta, GET_THREAD (ptid), &th) == 0) &&
- (td_thr_getname (th, name, 32) == 0))
- sprintf (buf, "Thread %ld (%s)", GET_THREAD (ptid), name);
- else
- sprintf (buf, "Thread %ld", GET_THREAD (ptid));
- }
else
sprintf (buf, "LWP %ld", GET_LWP (ptid));
@@ -597,19 +498,7 @@
if (nbsd_thread_active)
{
- if (IS_THREAD (ptid))
- {
- val = 0;
- if (td_map_id2thr (main_ta, GET_THREAD (ptid), &th) == 0)
- {
- /* Thread found */
- if ((td_thr_info (th, &ti) == 0) &&
- (ti.thread_state != TD_STATE_ZOMBIE) &&
- (ti.thread_type != TD_TYPE_SYSTEM))
- val = 1;
- }
- }
- else if (IS_LWP (ptid))
+ if (IS_LWP (ptid))
{
struct ptrace_lwpinfo pl;
pl.pl_lwpid = GET_LWP (ptid);
@@ -636,37 +525,11 @@
}
-/* Worker bee for find_new_threads
- Callback function that gets called once per USER thread (i.e., not
- kernel) thread. */
-
-static int
-nbsd_find_new_threads_callback (td_thread_t *th, void *ignored)
-{
- td_thread_info_t ti;
- ptid_t ptid;
-
- if (td_thr_info (th, &ti) != 0)
- return -1;
-
- ptid = BUILD_THREAD (ti.thread_id, main_ptid);
- if (ti.thread_type == TD_TYPE_USER &&
- ti.thread_state != TD_STATE_BLOCKED &&
- ti.thread_state != TD_STATE_ZOMBIE &&
- !in_thread_list (ptid))
- add_thread (ptid);
-
- return 0;
-}
-
static void
nbsd_find_new_threads (struct target_ops *ops)
{
int retval;
ptid_t ptid;
-#ifdef notyet
- td_thread_t *thread;
-#endif
if (nbsd_thread_active == 0)
return;
@@ -685,19 +548,11 @@
while ((retval != -1) && pl.pl_lwpid != 0)
{
ptid = BUILD_LWP (pl.pl_lwpid, main_ptid);
-#ifdef notyet
- td_map_lwp2thr (main_ta, pl.pl_lwpid, &thread);
-#endif
if (!in_thread_list (ptid))
add_thread (ptid);
retval = ptrace (PT_LWPINFO, GET_PID(inferior_ptid), (void *)&pl, sizeof(pl));
}
}
-
- retval = td_thr_iter (main_ta, nbsd_find_new_threads_callback, (void *) 0);
- if (retval != 0)
- error ("nbsd_find_new_threads: td_thr_iter: %s",
- td_err_string (retval));
}
@@ -720,269 +575,6 @@
}
-static int
-waiter_cb (td_thread_t *th, void *s)
-{
- int ret;
- td_thread_info_t ti;
-
- if ((ret = td_thr_info (th, &ti)) == 0)
- {
- wrap_here (NULL);
- printf_filtered (" %d", ti.thread_id);
- }
-
- return 0;
-}
-
-/* Worker bee for thread state command. This is a callback function that
- gets called once for each user thread (ie. not kernel thread) in the
- inferior. Print anything interesting that we can think of. */
-
-static int
-info_cb (td_thread_t *th, void *s)
-{
Home |
Main Index |
Thread Index |
Old Index