aboutsummaryrefslogtreecommitdiff
path: root/gnu/usr.bin
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2008-05-09 18:59:50 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2008-05-09 18:59:50 +0000
commitc80cc4444d026a807429e1b333fe81bf345b61c4 (patch)
tree5db5e721672d45a751792d86694420cefbcb7898 /gnu/usr.bin
parent7aaf8af3134dd5e6422c07312ac72d7ce5557f70 (diff)
Notes
Diffstat (limited to 'gnu/usr.bin')
-rw-r--r--gnu/usr.bin/gdb/kgdb/kthr.c14
-rw-r--r--gnu/usr.bin/gdb/kgdb/trgt.c50
-rw-r--r--gnu/usr.bin/gdb/kgdb/trgt_amd64.c2
-rw-r--r--gnu/usr.bin/gdb/kgdb/trgt_arm.c2
-rw-r--r--gnu/usr.bin/gdb/kgdb/trgt_i386.c4
-rw-r--r--gnu/usr.bin/gdb/kgdb/trgt_ia64.c2
-rw-r--r--gnu/usr.bin/gdb/kgdb/trgt_powerpc.c2
-rw-r--r--gnu/usr.bin/gdb/kgdb/trgt_sparc64.c2
8 files changed, 36 insertions, 42 deletions
diff --git a/gnu/usr.bin/gdb/kgdb/kthr.c b/gnu/usr.bin/gdb/kgdb/kthr.c
index 5759dc934a0e..d3c1411bc25d 100644
--- a/gnu/usr.bin/gdb/kgdb/kthr.c
+++ b/gnu/usr.bin/gdb/kgdb/kthr.c
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <kvm.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <defs.h>
#include <frame-unwind.h>
@@ -212,17 +213,20 @@ kgdb_thr_select(struct kthr *kt)
char *
kgdb_thr_extra_thread_info(int tid)
{
+ char comm[MAXCOMLEN + 1];
struct kthr *kt;
struct proc *p;
- static char comm[MAXCOMLEN + 1];
+ static char buf[64];
kt = kgdb_thr_lookup_tid(tid);
if (kt == NULL)
- return (NULL);
+ return (NULL);
+ snprintf(buf, sizeof(buf), "PID=%d", kt->pid);
p = (struct proc *)kt->paddr;
if (kvm_read(kvm, (uintptr_t)&p->p_comm[0], &comm, sizeof(comm)) !=
sizeof(comm))
- return (NULL);
-
- return (comm);
+ return (buf);
+ strlcat(buf, ": ", sizeof(buf));
+ strlcat(buf, comm, sizeof(buf));
+ return (buf);
}
diff --git a/gnu/usr.bin/gdb/kgdb/trgt.c b/gnu/usr.bin/gdb/kgdb/trgt.c
index 9898f6b3e3f6..14449b93af38 100644
--- a/gnu/usr.bin/gdb/kgdb/trgt.c
+++ b/gnu/usr.bin/gdb/kgdb/trgt.c
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <command.h>
#include <exec.h>
#include <frame-unwind.h>
+#include <gdb.h>
#include <gdbcore.h>
#include <gdbthread.h>
#include <inferior.h>
@@ -48,6 +49,7 @@ __FBSDID("$FreeBSD$");
#include <regcache.h>
#include <solib.h>
#include <target.h>
+#include <ui-out.h>
#include "kgdb.h"
@@ -125,11 +127,11 @@ kgdb_trgt_open(char *filename, int from_tty)
init_thread_list();
kt = kgdb_thr_init();
while (kt != NULL) {
- ti = add_thread(ptid_build(kt->pid, 0, kt->tid));
+ ti = add_thread(pid_to_ptid(kt->tid));
kt = kgdb_thr_next(kt);
}
if (curkthr != 0)
- inferior_ptid = ptid_build(curkthr->pid, 0, curkthr->tid);
+ inferior_ptid = pid_to_ptid(curkthr->tid);
if (ontop) {
/* XXX: fetch registers? */
@@ -187,14 +189,8 @@ kgdb_trgt_detach(char *args, int from_tty)
static char *
kgdb_trgt_extra_thread_info(struct thread_info *ti)
{
- static char buf[64];
- char *p, *s;
- p = buf + snprintf(buf, sizeof(buf), "PID=%d", ptid_get_pid(ti->ptid));
- s = kgdb_thr_extra_thread_info(ptid_get_tid(ti->ptid));
- if (s != NULL)
- snprintf(p, sizeof(buf) - (p - buf), ": %s", s);
- return (buf);
+ return (kgdb_thr_extra_thread_info(ptid_get_pid(ti->ptid)));
}
static void
@@ -224,14 +220,14 @@ kgdb_trgt_pid_to_str(ptid_t ptid)
{
static char buf[33];
- snprintf(buf, sizeof(buf), "Thread %ld", ptid_get_tid(ptid));
+ snprintf(buf, sizeof(buf), "Thread %d", ptid_get_pid(ptid));
return (buf);
}
static int
kgdb_trgt_thread_alive(ptid_t ptid)
{
- return (kgdb_thr_lookup_tid(ptid_get_tid(ptid)) != NULL);
+ return (kgdb_thr_lookup_tid(ptid_get_pid(ptid)) != NULL);
}
static int
@@ -260,16 +256,16 @@ kgdb_trgt_ignore_breakpoints(CORE_ADDR addr, char *contents)
}
static void
-kgdb_switch_to_thread(struct kthr *thr)
+kgdb_switch_to_thread(int tid)
{
- if (thr->tid == ptid_get_tid(inferior_ptid))
- return;
+ char buf[16];
+ int thread_id;
- inferior_ptid = ptid_build(thr->pid, 0, thr->tid);
- flush_cached_frames ();
- registers_changed ();
- stop_pc = read_pc ();
- select_frame (get_current_frame ());
+ thread_id = pid_to_thread_id(pid_to_ptid(tid));
+ if (thread_id == 0)
+ error ("invalid tid");
+ snprintf(buf, sizeof(buf), "%d", thread_id);
+ gdb_thread_select(uiout, buf);
}
static void
@@ -282,7 +278,7 @@ kgdb_set_proc_cmd (char *arg, int from_tty)
error_no_arg ("proc address for the new context");
if (kvm == NULL)
- error ("no kernel core file");
+ error ("only supported for core file target");
addr = (CORE_ADDR) parse_and_eval_address (arg);
@@ -295,7 +291,7 @@ kgdb_set_proc_cmd (char *arg, int from_tty)
if (thr == NULL)
error("invalid proc address");
}
- kgdb_switch_to_thread(thr);
+ kgdb_switch_to_thread(thr->tid);
}
static void
@@ -307,21 +303,15 @@ kgdb_set_tid_cmd (char *arg, int from_tty)
if (!arg)
error_no_arg ("TID or thread address for the new context");
- if (kvm == NULL)
- error ("no kernel core file");
-
addr = (CORE_ADDR) parse_and_eval_address (arg);
- if (!INKERNEL (addr)) {
- thr = kgdb_thr_lookup_tid((int)addr);
- if (thr == NULL)
- error ("invalid TID");
- } else {
+ if (kvm != NULL && INKERNEL (addr)) {
thr = kgdb_thr_lookup_taddr(addr);
if (thr == NULL)
error("invalid thread address");
+ addr = thr->tid;
}
- kgdb_switch_to_thread(thr);
+ kgdb_switch_to_thread(addr);
}
int fbsdcoreops_suppress_target = 1;
diff --git a/gnu/usr.bin/gdb/kgdb/trgt_amd64.c b/gnu/usr.bin/gdb/kgdb/trgt_amd64.c
index d37e9da68226..6f30c90d4d4c 100644
--- a/gnu/usr.bin/gdb/kgdb/trgt_amd64.c
+++ b/gnu/usr.bin/gdb/kgdb/trgt_amd64.c
@@ -50,7 +50,7 @@ kgdb_trgt_fetch_registers(int regno __unused)
struct kthr *kt;
struct pcb pcb;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
diff --git a/gnu/usr.bin/gdb/kgdb/trgt_arm.c b/gnu/usr.bin/gdb/kgdb/trgt_arm.c
index e99d5b204ee6..f2e292e5735d 100644
--- a/gnu/usr.bin/gdb/kgdb/trgt_arm.c
+++ b/gnu/usr.bin/gdb/kgdb/trgt_arm.c
@@ -55,7 +55,7 @@ kgdb_trgt_fetch_registers(int regno __unused)
struct pcb pcb;
int i, reg;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
diff --git a/gnu/usr.bin/gdb/kgdb/trgt_i386.c b/gnu/usr.bin/gdb/kgdb/trgt_i386.c
index f0546baf8b58..4afe4c794e3b 100644
--- a/gnu/usr.bin/gdb/kgdb/trgt_i386.c
+++ b/gnu/usr.bin/gdb/kgdb/trgt_i386.c
@@ -56,7 +56,7 @@ kgdb_trgt_fetch_registers(int regno __unused)
struct kthr *kt;
struct pcb pcb;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
@@ -133,7 +133,7 @@ kgdb_trgt_fetch_tss(void)
struct segment_descriptor sd;
uintptr_t addr, cpu0prvpage, tss;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL || kt->cpu == NOCPU)
return (0);
diff --git a/gnu/usr.bin/gdb/kgdb/trgt_ia64.c b/gnu/usr.bin/gdb/kgdb/trgt_ia64.c
index f9e0136f8ff1..4d5cea6cebbd 100644
--- a/gnu/usr.bin/gdb/kgdb/trgt_ia64.c
+++ b/gnu/usr.bin/gdb/kgdb/trgt_ia64.c
@@ -52,7 +52,7 @@ kgdb_trgt_fetch_registers(int regno __unused)
struct pcb pcb;
uint64_t r;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
diff --git a/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c b/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c
index 95e616190c24..6b8731b8e836 100644
--- a/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c
+++ b/gnu/usr.bin/gdb/kgdb/trgt_powerpc.c
@@ -54,7 +54,7 @@ kgdb_trgt_fetch_registers(int regno __unused)
tdep = gdbarch_tdep (current_gdbarch);
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {
diff --git a/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c b/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c
index 736a499d41e6..8fece2419a92 100644
--- a/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c
+++ b/gnu/usr.bin/gdb/kgdb/trgt_sparc64.c
@@ -52,7 +52,7 @@ kgdb_trgt_fetch_registers(int regno __unused)
struct kthr *kt;
struct pcb pcb;
- kt = kgdb_thr_lookup_tid(ptid_get_tid(inferior_ptid));
+ kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid));
if (kt == NULL)
return;
if (kvm_read(kvm, kt->pcb, &pcb, sizeof(pcb)) != sizeof(pcb)) {