From: Nick Duffek <nsd@redhat.com>
To: jtc@redback.com, cagney@cygnus.com
Cc: gdb-patches@sources.redhat.com
Subject: [RFA] add remote.c gdbarch thread-handling hooks
Date: Mon, 16 Jul 2001 10:26:00 -0000 [thread overview]
Message-ID: <200107161726.f6GHQ8P08542@rtl.cygnus.com> (raw)
Hi,
I've been working on an architecture with a primitive threading mechanism
that GDB queries and manipulates by directly setting registers in the
target.
This patch facilitates that with hooks for target-specific code to
override remote.c thread-handling functions.
It also fixes a few typos in init_remote_cisco_ops() and
init_remote_async_ops() and moves assignment of a few target_ops fields to
be consistent with ordering in target.h.
ChangeLog:
* gdbarch.sh (REMOTE_SET_THREAD, REMOTE_THREAD_ALIVE,
REMOTE_CURRENT_THREAD, REMOTE_THREADS_INFO,
REMOTE_THREADS_EXTRA_INFO, REMOTE_PID_TO_STR): New functions.
(struct thread_info): New forward declaration.
* remote.c (set_thread): Call REMOTE_SET_THREAD if defined.
(remote_thread_alive): Call REMOTE_THREAD_ALIVE if defined.
(remote_current_thread, remote_wait, remote_async_wait): Call
REMOTE_CURRENT_THREAD if defined.
(remote_threads_info): Call REMOTE_THREADS_INFO if defined.
(remote_threads_extra_info): Call REMOTE_THREADS_EXTRA_INFO if
defined.
(remote_pid_to_str): Call REMOTE_PID_TO_STR if defined.
(init_remote_ops, init_remote_cisco_ops, init_remote_async_ops):
Set to_pid_to_str and to_extra_thread_info correctly and in the
same order as declared in target.h.
Okay to apply?
Nick Duffek
<nsd@redhat.com>
[patch follows]
Index: gdb/gdbarch.sh
===================================================================
diff -up gdb/gdbarch.sh gdb/gdbarch.sh
--- gdb/gdbarch.sh Mon Jul 16 13:19:25 2001
+++ gdb/gdbarch.sh Mon Jul 16 13:19:19 2001
@@ -495,6 +495,20 @@ f::PREPARE_TO_PROCEED:int:prepare_to_pro
v:2:FUNCTION_START_OFFSET:CORE_ADDR:function_start_offset::::0:-1
#
f:2:REMOTE_TRANSLATE_XFER_ADDRESS:void:remote_translate_xfer_address:CORE_ADDR gdb_addr, int gdb_len, CORE_ADDR *rem_addr, int *rem_len:gdb_addr, gdb_len, rem_addr, rem_len:::generic_remote_translate_xfer_address::0
+# Set the remote system's current thread to TID, in preparation for general
+# queries (e.g. register fetch) if GEN and for continuing execution
+# otherwise. TID 0 means all threads, -1 means any thread.
+F:2:REMOTE_SET_THREAD:void:remote_set_thread:int tid, int gen:tid, gen::0
+# Return whether thread TID is still alive on the remote system.
+F:2:REMOTE_THREAD_ALIVE:int:remote_thread_alive:int tid:tid::0
+# Return the remote system's current thread id if known, else return PREVTID.
+F:2:REMOTE_CURRENT_THREAD:int:remote_current_thread:int prevtid:prevtid::0
+# Query the remote system for new threads and add them to the thread list.
+F:2:REMOTE_THREADS_INFO:void:remote_threads_info:void:::0
+# Return a static string describing the state of thread TP->pid.
+F:2:REMOTE_THREADS_EXTRA_INFO:char *:remote_threads_extra_info:struct thread_info *tp:tp::0
+# Return a static string representation of internal gdb process id PID.
+F:2:REMOTE_PID_TO_STR:char *:remote_pid_to_str:ptid_t ptid:ptid::0
#
v:2:FRAME_ARGS_SKIP:CORE_ADDR:frame_args_skip::::0:-1
f:2:FRAMELESS_FUNCTION_INVOCATION:int:frameless_function_invocation:struct frame_info *fi:fi:::generic_frameless_function_invocation_not::0
@@ -625,6 +639,7 @@ cat <<EOF
#define GDBARCH_H
struct frame_info;
+struct thread_info;
struct value;
Index: gdb/remote.c
===================================================================
diff -up gdb/remote.c gdb/remote.c
--- gdb/remote.c Mon Jul 16 13:19:31 2001
+++ gdb/remote.c Mon Jul 16 13:19:19 2001
@@ -937,6 +937,12 @@ set_thread (int th, int gen)
char *buf = alloca (PBUFSIZ);
int state = gen ? general_thread : continue_thread;
+ if (REMOTE_SET_THREAD_P ())
+ {
+ REMOTE_SET_THREAD (th, gen);
+ return;
+ }
+
if (state == th)
return;
@@ -967,6 +973,9 @@ remote_thread_alive (ptid_t ptid)
int tid = PIDGET (ptid);
char buf[16];
+ if (REMOTE_THREAD_ALIVE_P ())
+ return REMOTE_THREAD_ALIVE (tid);
+
if (tid < 0)
sprintf (buf, "T-%08x", -tid);
else
@@ -1654,6 +1663,9 @@ remote_current_thread (ptid_t oldpid)
{
char *buf = alloca (PBUFSIZ);
+ if (REMOTE_CURRENT_THREAD_P ())
+ return pid_to_ptid (REMOTE_CURRENT_THREAD (PIDGET (oldpid)));
+
putpkt ("qC");
getpkt (buf, PBUFSIZ, 0);
if (buf[0] == 'Q' && buf[1] == 'C')
@@ -1692,6 +1704,12 @@ remote_threads_info (void)
if (remote_desc == 0) /* paranoia */
error ("Command can only be used when connected to the remote target.");
+ if (REMOTE_THREADS_INFO_P ())
+ {
+ REMOTE_THREADS_INFO ();
+ return;
+ }
+
if (use_threadinfo_query)
{
putpkt ("qfThreadInfo");
@@ -1746,6 +1764,9 @@ remote_threads_extra_info (struct thread
internal_error (__FILE__, __LINE__,
"remote_threads_extra_info");
+ if (REMOTE_THREADS_EXTRA_INFO_P ())
+ return REMOTE_THREADS_EXTRA_INFO (tp);
+
if (use_threadextra_query)
{
sprintf (bufp, "qThreadExtraInfo,%x", PIDGET (tp->ptid));
@@ -3062,6 +3083,13 @@ Packet Dropped");
}
}
got_status:
+
+ if (REMOTE_CURRENT_THREAD_P () && status->kind == TARGET_WAITKIND_STOPPED)
+ {
+ thread_num = REMOTE_CURRENT_THREAD (thread_num);
+ if (thread_num != -1)
+ record_currthread (thread_num);
+ }
if (thread_num != -1)
{
return pid_to_ptid (thread_num);
@@ -3284,6 +3312,13 @@ Packet Dropped");
}
}
got_status:
+
+ if (REMOTE_CURRENT_THREAD_P () && status->kind == TARGET_WAITKIND_STOPPED)
+ {
+ thread_num = REMOTE_CURRENT_THREAD (thread_num);
+ if (thread_num != -1)
+ record_currthread (thread_num);
+ }
if (thread_num != -1)
{
return pid_to_ptid (thread_num);
@@ -5197,6 +5232,9 @@ remote_pid_to_str (ptid_t ptid)
{
static char buf[30];
+ if (REMOTE_PID_TO_STR_P ())
+ return REMOTE_PID_TO_STR (ptid);
+
sprintf (buf, "Thread %d", PIDGET (ptid));
return buf;
}
@@ -5227,8 +5265,8 @@ Specify the serial device it is connecte
remote_ops.to_mourn_inferior = remote_mourn;
remote_ops.to_thread_alive = remote_thread_alive;
remote_ops.to_find_new_threads = remote_threads_info;
- remote_ops.to_extra_thread_info = remote_threads_extra_info;
remote_ops.to_pid_to_str = remote_pid_to_str;
+ remote_ops.to_extra_thread_info = remote_threads_extra_info;
remote_ops.to_stop = remote_stop;
remote_ops.to_query = remote_query;
remote_ops.to_rcmd = remote_rcmd;
@@ -5636,7 +5674,8 @@ Specify the serial device it is connecte
remote_cisco_ops.to_mourn_inferior = remote_cisco_mourn;
remote_cisco_ops.to_thread_alive = remote_thread_alive;
remote_cisco_ops.to_find_new_threads = remote_threads_info;
- remote_ops.to_extra_thread_info = remote_threads_extra_info;
+ remote_cisco_ops.to_pid_to_str = remote_pid_to_str;
+ remote_cisco_ops.to_extra_thread_info = remote_threads_extra_info;
remote_cisco_ops.to_stratum = process_stratum;
remote_cisco_ops.to_has_all_memory = 1;
remote_cisco_ops.to_has_memory = 1;
@@ -5726,7 +5765,8 @@ Specify the serial device it is connecte
remote_async_ops.to_mourn_inferior = remote_async_mourn;
remote_async_ops.to_thread_alive = remote_thread_alive;
remote_async_ops.to_find_new_threads = remote_threads_info;
- remote_ops.to_extra_thread_info = remote_threads_extra_info;
+ remote_async_ops.to_pid_to_str = remote_pid_to_str;
+ remote_async_ops.to_extra_thread_info = remote_threads_extra_info;
remote_async_ops.to_stop = remote_stop;
remote_async_ops.to_query = remote_query;
remote_async_ops.to_rcmd = remote_rcmd;
next reply other threads:[~2001-07-16 10:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-07-16 10:26 Nick Duffek [this message]
2001-07-16 11:14 ` Andrew Cagney
2001-07-16 16:34 ` Nick Duffek
2001-07-16 12:21 ` J.T. Conklin
[not found] <3B537C79.9060108@cygnus.com>
2001-07-16 17:40 ` Nick Duffek
2001-07-16 20:22 ` Andrew Cagney
[not found] <3B5386C6.9020904@cygnus.com>
2001-07-16 18:20 ` Nick Duffek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200107161726.f6GHQ8P08542@rtl.cygnus.com \
--to=nsd@redhat.com \
--cc=cagney@cygnus.com \
--cc=gdb-patches@sources.redhat.com \
--cc=jtc@redback.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox