PERFORCE change 57580 for review
David Xu
davidxu at FreeBSD.org
Sat Jul 17 20:12:37 PDT 2004
http://perforce.freebsd.org/chv.cgi?CH=57580
Change 57580 by davidxu at davidxu_alona on 2004/07/18 03:11:49
resolve conflict with @57576
Affected files ...
.. //depot/projects/davidxu_ksedbg/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#13 integrate
.. //depot/projects/davidxu_ksedbg/src/include/proc_service.h#5 integrate
.. //depot/projects/davidxu_ksedbg/src/lib/libthread_db/Makefile#2 integrate
.. //depot/projects/davidxu_ksedbg/src/lib/libthread_db/include/thread_db_int.h#2 integrate
.. //depot/projects/davidxu_ksedbg/src/lib/libthread_db/pthread/Makefile#2 integrate
.. //depot/projects/davidxu_ksedbg/src/lib/libthread_db/pthread/pthread_db.c#9 integrate
.. //depot/projects/davidxu_ksedbg/src/lib/libthread_db/pthread/pthread_db.h#3 integrate
.. //depot/projects/davidxu_ksedbg/src/lib/libthread_db/pthread/pthread_db_i386.c#2 integrate
.. //depot/projects/davidxu_ksedbg/src/lib/libthread_db/src/Makefile#2 integrate
.. //depot/projects/davidxu_ksedbg/src/lib/libthread_db/src/thread_db.c#3 integrate
Differences ...
==== //depot/projects/davidxu_ksedbg/src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c#13 (text+ko) ====
@@ -1,4 +1,4 @@
-/* $FreeBSD: src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c,v 1.2 2004/07/16 06:11:48 davidxu Exp $ */
+/* $FreeBSD: src/gnu/usr.bin/gdb/libgdb/fbsd-threads.c,v 1.3 2004/07/17 17:08:13 marcel Exp $ */
/* FreeBSD libthread_db assisted debugging support.
Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
@@ -70,7 +70,7 @@
static td_thragent_t *thread_agent;
/* The last thread we are single stepping */
-static lwpid_t last_single_step_lwp;
+static ptid_t last_single_step_thread;
/* Pointers to the libthread_db functions. */
@@ -383,7 +383,7 @@
td_thrinfo_t ti;
ptid_t work_ptid;
int resume_all, ret;
- long lwp;
+ long lwp, thvalid = 0;
#if 0
printf_filtered("%s ptid=%ld.%ld.%ld step=%d\n", __func__,
@@ -399,7 +399,7 @@
return;
}
- if (GET_PID (ptid) != -1 && step != 0)
+ if (GET_PID(ptid) != -1 && step != 0)
{
resume_all = 0;
work_ptid = ptid;
@@ -432,59 +432,49 @@
ret = td_thr_get_info_p (&th, &ti);
if (ret)
error (thread_db_err_str (ret));
+ thvalid = 1;
lwp = ti.ti_lid;
}
- if (!resume_all && lwp == 0)
- {
- error ("sorry this version of FreeBSD can not resume inactivated thread");
- }
-
if (lwp)
{
int req = step ? PT_SETSTEP : PT_CLEARSTEP;
- if (ptrace (req, (pid_t) lwp, 0, 0))
+ if (ptrace (req, (pid_t) lwp, (caddr_t) 1, target_signal_to_host(signo)))
perror_with_name ("PT_SETSTEP/PT_CLEARSTEP");
}
- int nlwps = ptrace (PT_GETNUMLWPS, proc_handle.pid, 0, 0);
- if (nlwps == -1)
- perror_with_name ("PT_GETNUMLWPS");
- lwpid_t *lwps = malloc (nlwps * sizeof(lwpid_t));
- nlwps = ptrace (PT_GETLWPLIST, proc_handle.pid, (caddr_t)lwps, nlwps);
- if (nlwps == -1)
+ if (!ptid_equal (last_single_step_thread, null_ptid))
{
- perror_with_name ("PT_GETLWPLIST");
- free (lwps);
+ ret = td_ta_thr_iter_p (thread_agent, resume_thread_callback, NULL,
+ TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
+ TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
+ if (ret != TD_OK)
+ error ("resume error: %s", thread_db_err_str (ret));
}
- int i;
- if (last_single_step_lwp != 0)
+ if (!resume_all)
{
- /* resume all threads if ever suspend them */
- for (i = 0; i < nlwps; ++i)
- {
- if (ptrace (PT_RESUME, lwps[i], 0, 0))
- perror_with_name ("PT_SUSPEND");
- }
+ ret = td_ta_thr_iter_p (thread_agent, suspend_thread_callback, NULL,
+ TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY,
+ TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS);
+ if (ret != TD_OK)
+ error ("suspend error: %s", thread_db_err_str (ret));
+ last_single_step_thread = work_ptid;
}
+ else
+ last_single_step_thread = null_ptid;
- if (!resume_all)
+ if (thvalid)
{
- for (i = 0; i < nlwps; ++i)
- {
- if (lwps[i] == lwp)
- continue;
- if (ptrace (PT_SUSPEND, lwps[i], 0, 0))
- perror_with_name ("PT_SUSPEND");
- }
- last_single_step_lwp = lwp;
+ ret = td_thr_dbresume_p (&th);
+ if (ret != TD_OK)
+ error ("resume error: %s", thread_db_err_str (ret));
}
else
- last_single_step_lwp = 0;
-
- free (lwps);
-/* ret = ptrace(PT_RESUME, lwp, 0, 0); */
+ {
+ /* it is not necessary, put it here for completness */
+ ret = ptrace(PT_RESUME, lwp, 0, 0);
+ }
/* now continue the process, suspended thread wont run */
if (ptrace (PT_CONTINUE, proc_handle.pid , (caddr_t)1,
@@ -1007,62 +997,69 @@
}
ps_err_e
-ps_pdread (struct ps_prochandle *ph, psaddr_t addr, void *buf, size_t len)
+ps_pread (struct ps_prochandle *ph, psaddr_t addr, void *buf, size_t len)
{
return target_read_memory ((CORE_ADDR) addr, buf, len);
}
ps_err_e
-ps_pdwrite (struct ps_prochandle *ph, psaddr_t addr, const void *buf,
+ps_pwrite (struct ps_prochandle *ph, psaddr_t addr, const void *buf,
size_t len)
{
return target_write_memory ((CORE_ADDR) addr, (void *)buf, len);
}
ps_err_e
-ps_ptread (struct ps_prochandle *ph, psaddr_t addr, void *buf, size_t len)
+ps_lgetregs (struct ps_prochandle *ph, lwpid_t lwpid, prgregset_t gregset)
{
- return target_read_memory ((CORE_ADDR) addr, buf, len);
-}
+ struct cleanup *old_chain;
-ps_err_e
-ps_ptwrite (struct ps_prochandle *ph, psaddr_t addr, const void *buf,
- size_t len)
-{
- return target_write_memory ((CORE_ADDR) addr, (void *)buf, len);
+ old_chain = save_inferior_ptid ();
+ inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+ target_fetch_registers (-1);
+ fill_gregset (gregset, -1);
+ do_cleanups (old_chain);
+ return PS_OK;
}
ps_err_e
-ps_lgetregs (struct ps_prochandle *ph, lwpid_t lwpid, prgregset_t gregset)
+ps_lsetregs (struct ps_prochandle *ph, lwpid_t lwpid, const prgregset_t gregset)
{
- if (ptrace (PT_GETREGS, lwpid, (caddr_t)gregset, 0) == 0)
- return PS_OK;
- return PS_ERR;
-}
+ struct cleanup *old_chain;
-ps_err_e
-ps_lsetregs (struct ps_prochandle *ph, lwpid_t lwpid, const prgregset_t gregset)
-{
- if (ptrace (PT_SETREGS, lwpid, (caddr_t)gregset, 0) == 0)
- return PS_OK;
- return PS_ERR;
+ old_chain = save_inferior_ptid ();
+ inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+ supply_gregset (gregset);
+ target_store_registers (-1);
+ do_cleanups (old_chain);
+ return PS_OK;
}
ps_err_e
ps_lgetfpregs (struct ps_prochandle *ph, lwpid_t lwpid, prfpregset_t *fpregset)
{
- if (ptrace (PT_GETFPREGS, lwpid, (caddr_t)fpregset, 0) == 0)
- return PS_OK;
- return PS_ERR;
+ struct cleanup *old_chain;
+
+ old_chain = save_inferior_ptid ();
+ inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+ target_fetch_registers (-1);
+ fill_fpregset (fpregset, -1);
+ do_cleanups (old_chain);
+ return PS_OK;
}
ps_err_e
ps_lsetfpregs (struct ps_prochandle *ph, lwpid_t lwpid,
const prfpregset_t *fpregset)
{
- if (ptrace (PT_SETFPREGS, lwpid, (caddr_t)fpregset, 0) == 0)
- return PS_OK;
- return PS_ERR;
+ struct cleanup *old_chain;
+
+ old_chain = save_inferior_ptid ();
+ inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid));
+ supply_fpregset (fpregset);
+ target_store_registers (-1);
+ do_cleanups (old_chain);
+ return PS_OK;
}
ps_err_e
@@ -1080,10 +1077,3 @@
return PS_ERR;
return PS_OK;
}
-
-pid_t
-ps_getpid (struct ps_prochandle *ph)
-{
- return ph->pid;
-}
-
==== //depot/projects/davidxu_ksedbg/src/include/proc_service.h#5 (text+ko) ====
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2004 David Xu <davidxu at freebsd.org>
+ * Copyright (c) 2004 Marcel Moolenaar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -10,18 +11,11 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -30,74 +24,42 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: src/include/proc_service.h,v 1.2 2004/07/17 17:05:12 marcel Exp $
*/
#ifndef _PROC_SERVICE_H_
-#define _PROC_SERVICE_H_
+#define _PROC_SERVICE_H_
#include <sys/types.h>
#include <sys/procfs.h>
-struct ps_prochandle;
+typedef enum {
+ PS_OK = 0, /* No errors. */
+ PS_ERR, /* Generic error. */
+ PS_BADADDR, /* Bad address. */
+ PS_BADLID, /* Bad LWP Id. */
+ PS_BADPID, /* Bad process Id. */
+ PS_NOFREGS, /* FPU register set not available. */
+ PS_NOSYM /* Symbol not found. */
+} ps_err_e;
-typedef enum
-{
- PS_OK,
- PS_ERR,
- PS_BADPID,
- PS_BADLID,
- PS_BADADDR,
- PS_NOSYM,
- PS_NOFREGS
-} ps_err_e;
+struct ps_prochandle; /* Opaque type. Defined by the implementor. */
-/*
- * Every program that links libthread_db must provide a set of process control
- * primitives to access memory and registers in the target process, to start
- * and to stop the target process, and to look up symbols in the target process.
- */
+__BEGIN_DECLS
+ps_err_e ps_lcontinue(struct ps_prochandle *, lwpid_t);
+ps_err_e ps_lgetfpregs(struct ps_prochandle *, lwpid_t, prfpregset_t *);
+ps_err_e ps_lgetregs(struct ps_prochandle *, lwpid_t, prgregset_t);
+ps_err_e ps_lsetfpregs(struct ps_prochandle *, lwpid_t, const prfpregset_t *);
+ps_err_e ps_lsetregs(struct ps_prochandle *, lwpid_t, const prgregset_t);
+ps_err_e ps_lstop(struct ps_prochandle *, lwpid_t);
+ps_err_e ps_pcontinue(struct ps_prochandle *);
+ps_err_e ps_pdmodel(struct ps_prochandle *, int *);
+ps_err_e ps_pglobal_lookup(struct ps_prochandle *, const char *, const char *,
+ psaddr_t *);
+void ps_plog(const char *, ...);
+ps_err_e ps_pread(struct ps_prochandle *, psaddr_t, void *, size_t);
+ps_err_e ps_pstop(struct ps_prochandle *);
+ps_err_e ps_pwrite(struct ps_prochandle *, psaddr_t, const void *, size_t);
+__END_DECLS
-#if 0
-ps_err_e ps_pdmodel(struct ps_prochandle *ph, int *data_model);
-#endif
-ps_err_e ps_pglobal_lookup(struct ps_prochandle *ph, const char *object_name,
- const char *sym_name , psaddr_t *sym_addr);
-#if 0
-ps_err_e ps_pglobal_sym(struct ps_prochandle *ph, const char *object_name,
- const char *sym_name , ps_sym_t *sym);
-ps_err_e ps_pread(struct ps_prochandle *ph, psaddr_t addr, void *buf,
- size_t size);
-ps_err_e ps_pwrite(struct ps_prochandle *ph, psaddr_t addr, const void *buf,
- size_t size);
-#endif
-ps_err_e ps_pdread(struct ps_prochandle *ph, psaddr_t addr, void *buf,
- size_t size);
-ps_err_e ps_pdwrite(struct ps_prochandle *ph, psaddr_t addr, const void *buf,
- size_t size);
-ps_err_e ps_ptread(struct ps_prochandle *ph, psaddr_t addr, void *buf,
- size_t size);
-ps_err_e ps_ptwrite(struct ps_prochandle *ph, psaddr_t addr, const void *buf,
- size_t size);
-ps_err_e ps_pstop(struct ps_prochandle *ph);
-ps_err_e ps_pcontinue(struct ps_prochandle *ph);
-ps_err_e ps_lstop(struct ps_prochandle *ph, lwpid_t lwpid);
-ps_err_e ps_lcontinue(struct ps_prochandle *ph, lwpid_t lwpid);
-ps_err_e ps_lgetregs(struct ps_prochandle *ph, lwpid_t lwpid,
- prgregset_t gregset);
-ps_err_e ps_lsetregs(struct ps_prochandle *ph, lwpid_t lwpid,
- const prgregset_t gregset);
-ps_err_e ps_lgetfpregs(struct ps_prochandle *ph, lwpid_t lwpid,
- prfpregset_t *fpregset);
-ps_err_e ps_lsetfpregs(struct ps_prochandle *ph, lwpid_t lwpid,
- const prfpregset_t *fpregset);
-#if 0
-ps_err_e ps_pauxv(struct ps_prochandle *ph, const auxv_t **auxp);
-ps_err_e ps_kill(struct ps_prochandle *ph, int sig);
-ps_err_e ps_lrolltoaddr(struct ps_prochandle *ph, lwpid_t lwpid,
- psaddr_t go_addr, psaddr_t stop_addr);
-#endif
-void ps_plog(const char *fmt, ...);
-pid_t ps_getpid (struct ps_prochandle *ph);
-
-#endif
+#endif /* _PROC_SERVICE_H_ */
==== //depot/projects/davidxu_ksedbg/src/lib/libthread_db/Makefile#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: src/lib/libthread_db/Makefile,v 1.1 2004/07/15 03:36:35 davidxu Exp $
SUBDIR=pthread src
==== //depot/projects/davidxu_ksedbg/src/lib/libthread_db/include/thread_db_int.h#2 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: src/lib/libthread_db/include/thread_db_int.h,v 1.2 2004/07/17 17:09:12 marcel Exp $
*/
#ifndef _THREAD_DB_INT_H
@@ -64,7 +64,7 @@
td_err_e (*to_thr_getxregs)(const td_thrhandle_t *, void *);
td_err_e (*to_thr_getxregsize)(const td_thrhandle_t *, int *);
td_err_e (*to_thr_setfpregs)(const td_thrhandle_t *, const prfpregset_t *);
- td_err_e (*to_thr_setgregs)(const td_thrhandle_t *, prgregset_t);
+ td_err_e (*to_thr_setgregs)(const td_thrhandle_t *, const prgregset_t);
td_err_e (*to_thr_setxregs)(const td_thrhandle_t *, const void *);
td_err_e (*to_thr_event_enable)(const td_thrhandle_t *, int);
td_err_e (*to_thr_set_event)(const td_thrhandle_t *, td_thr_events_t *);
==== //depot/projects/davidxu_ksedbg/src/lib/libthread_db/pthread/Makefile#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: src/lib/libthread_db/pthread/Makefile,v 1.1 2004/07/15 03:36:35 davidxu Exp $
LIB=pthread_db
INTERNALLIB=yes
==== //depot/projects/davidxu_ksedbg/src/lib/libthread_db/pthread/pthread_db.c#9 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libthread_db/pthread/pthread_db.c,v 1.1 2004/07/15 03:36:35 davidxu Exp $");
+__FBSDID("$FreeBSD: src/lib/libthread_db/pthread/pthread_db.c,v 1.2 2004/07/17 17:09:12 marcel Exp $");
#include <stddef.h>
#include <stdlib.h>
@@ -662,7 +662,7 @@
}
static td_err_e
-pt_thr_setgregs(const td_thrhandle_t *th, prgregset_t gregs)
+pt_thr_setgregs(const td_thrhandle_t *th, const prgregset_t gregs)
{
struct kse_thr_mailbox tmbx;
pt_thragent_t *ta = (pt_thragent_t *)th->th_ta_p;
@@ -842,6 +842,21 @@
ret = ps_pdread(ta->ph, ptr, &lwp, sizeof(lwpid_t));
if (ret != 0)
return (P2T(ret));
+ /*
+ * don't stop lwp assigned to a M:N thread, it belongs
+ * to UTS, UTS shouldn't be stopped.
+ */
+ if (lwp != 0 && (attrflags & PTHREAD_SCOPE_SYSTEM)) {
+ /* dont' suspend signal thread */
+ if (attrflags & THR_SIGNAL_THREAD)
+ return 0;
+ if (suspend)
+ ret = ps_lstop(ta->ph, lwp);
+ else
+ ret = ps_lcontinue(ta->ph, lwp);
+ return (P2T(ret));
+ }
+
ret = ps_pdread(ta->ph,
tmbx_addr + offsetof(struct kse_thr_mailbox, tm_dflags),
&dflags, sizeof(dflags));
@@ -855,24 +870,6 @@
ret = ps_pdwrite(ta->ph,
tmbx_addr + offsetof(struct kse_thr_mailbox, tm_dflags),
&dflags, sizeof(dflags));
- if (ret)
- return (P2T(ret));
- /*
- * don't stop lwp assigned to a M:N thread, it belongs
- * to UTS, UTS shouldn't be stopped.
- */
- if (lwp != 0) {/* && (attrflags & PTHREAD_SCOPE_SYSTEM)) { */
- /* dont' suspend signal thread */
-#if 0
- if (attrflags & THR_SIGNAL_THREAD)
- return 0;
-#endif
- if (suspend)
- ret = ps_lstop(ta->ph, lwp);
- else
- ret = ps_lcontinue(ta->ph, lwp);
- }
-
return (P2T(ret));
}
==== //depot/projects/davidxu_ksedbg/src/lib/libthread_db/pthread/pthread_db.h#3 (text+ko) ====
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: src/lib/libthread_db/pthread/pthread_db.h,v 1.1 2004/07/15 03:36:35 davidxu Exp $
*/
#ifndef _PTHREAD_DB_H
==== //depot/projects/davidxu_ksedbg/src/lib/libthread_db/pthread/pthread_db_i386.c#2 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libthread_db/pthread/pthread_db_i386.c,v 1.1 2004/07/15 03:36:35 davidxu Exp $");
#include <string.h>
#include <sys/types.h>
==== //depot/projects/davidxu_ksedbg/src/lib/libthread_db/src/Makefile#2 (text+ko) ====
@@ -1,4 +1,4 @@
-# $FreeBSD$
+# $FreeBSD: src/lib/libthread_db/src/Makefile,v 1.1 2004/07/15 03:36:35 davidxu Exp $
SHLIB_NAME=libthread_db.so.1
NOPROFILE=yes
@@ -10,5 +10,6 @@
.PATH: ${.CURDIR}
SRCS+=thread_db.c
+INCS=../include/thread_db.h
.include <bsd.lib.mk>
==== //depot/projects/davidxu_ksedbg/src/lib/libthread_db/src/thread_db.c#3 (text+ko) ====
@@ -25,7 +25,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: src/lib/libthread_db/src/thread_db.c,v 1.2 2004/07/17 17:09:12 marcel Exp $");
#include <stddef.h>
#include <unistd.h>
@@ -232,7 +232,7 @@
}
td_err_e
-td_thr_setgregs(const td_thrhandle_t *th, prgregset_t gregs)
+td_thr_setgregs(const td_thrhandle_t *th, const prgregset_t gregs)
{
td_thragent_t *ta = th->th_ta_p;
More information about the p4-projects
mailing list