mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-17 15:27:36 +00:00
In kthr.c, obtain the address of the PCB for threads that were running
on a core, when the core was stopped, by calling kgdb_trgt_core_pcb(). This has 2 advantages: 1. We don't need to include a machine-specific header anymore and as such kthr.c is truly machine independent. This allows the code to be used in a cross-debugger. 2. We don't need to lookup stoppcbs in generic code when it's an inherently target-spicific symbol. It does not exist for ia64. Implement kgdb_trgt_core_pcb() for all architectures, except ia64, by calling a common function called kgdb_trgt_stop_pcb(). This function differs from kgdb_trgt_core_pcb() in that it gets the size of the PCB structure as an argument and as such remains machine independent. On ia64 the PCB for stopped cores is in the PCPU structure itself. This for better scaling. The implementation of kgdb_trgt_core_pcb() for ia64 uses the cpuid_to_pcpu[] array to to obtain the address of the PCB structure.
This commit is contained in:
parent
acbaa69f31
commit
d7aa5f02d0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=246893
@ -49,6 +49,8 @@ extern struct kthr *curkthr;
|
||||
void initialize_kld_target(void);
|
||||
void initialize_kgdb_target(void);
|
||||
void kgdb_dmesg(void);
|
||||
CORE_ADDR kgdb_trgt_core_pcb(u_int);
|
||||
CORE_ADDR kgdb_trgt_stop_pcb(u_int, u_int);
|
||||
void kgdb_trgt_new_objfile(struct objfile *);
|
||||
void kgdb_trgt_fetch_registers(int);
|
||||
void kgdb_trgt_store_registers(int);
|
||||
|
@ -44,12 +44,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include <frame-unwind.h>
|
||||
|
||||
#include "kgdb.h"
|
||||
#include <machine/pcb.h>
|
||||
|
||||
static CORE_ADDR dumppcb;
|
||||
static int dumptid;
|
||||
|
||||
static CORE_ADDR stoppcbs;
|
||||
static cpuset_t stopped_cpus;
|
||||
|
||||
static struct kthr *first;
|
||||
@ -98,10 +96,9 @@ kgdb_thr_add_procs(uintptr_t paddr)
|
||||
kt->kaddr = addr;
|
||||
if (td.td_tid == dumptid)
|
||||
kt->pcb = dumppcb;
|
||||
else if (td.td_state == TDS_RUNNING && stoppcbs != 0 &&
|
||||
else if (td.td_state == TDS_RUNNING &&
|
||||
CPU_ISSET(td.td_oncpu, &stopped_cpus))
|
||||
kt->pcb = (uintptr_t)stoppcbs +
|
||||
sizeof(struct pcb) * td.td_oncpu;
|
||||
kt->pcb = kgdb_trgt_core_pcb(td.td_oncpu);
|
||||
else
|
||||
kt->pcb = (uintptr_t)td.td_pcb;
|
||||
kt->kstack = td.td_kstack;
|
||||
@ -152,8 +149,6 @@ kgdb_thr_init(void)
|
||||
addr != 0)
|
||||
kvm_read(kvm, addr, &stopped_cpus, cpusetsize);
|
||||
|
||||
stoppcbs = kgdb_lookup("stoppcbs");
|
||||
|
||||
kgdb_thr_add_procs(paddr);
|
||||
addr = kgdb_lookup("zombproc");
|
||||
if (addr != 0) {
|
||||
|
@ -53,6 +53,8 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "kgdb.h"
|
||||
|
||||
static CORE_ADDR stoppcbs;
|
||||
|
||||
static void kgdb_core_cleanup(void *);
|
||||
|
||||
static char *vmcore;
|
||||
@ -352,3 +354,18 @@ initialize_kgdb_target(void)
|
||||
add_com ("tid", class_obscure, kgdb_set_tid_cmd,
|
||||
"Set current thread context");
|
||||
}
|
||||
|
||||
CORE_ADDR
|
||||
kgdb_trgt_stop_pcb(u_int cpuid, u_int pcbsz)
|
||||
{
|
||||
static int once = 0;
|
||||
|
||||
if (stoppcbs == 0 && !once) {
|
||||
once = 1;
|
||||
stoppcbs = kgdb_lookup("stoppcbs");
|
||||
}
|
||||
if (stoppcbs == 0)
|
||||
return 0;
|
||||
|
||||
return (stoppcbs + pcbsz * cpuid);
|
||||
}
|
||||
|
@ -44,6 +44,12 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "kgdb.h"
|
||||
|
||||
CORE_ADDR
|
||||
kgdb_trgt_core_pcb(u_int cpuid)
|
||||
{
|
||||
return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb)));
|
||||
}
|
||||
|
||||
void
|
||||
kgdb_trgt_fetch_registers(int regno __unused)
|
||||
{
|
||||
|
@ -47,6 +47,12 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "kgdb.h"
|
||||
|
||||
CORE_ADDR
|
||||
kgdb_trgt_core_pcb(u_int cpuid)
|
||||
{
|
||||
return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb)));
|
||||
}
|
||||
|
||||
void
|
||||
kgdb_trgt_fetch_registers(int regno __unused)
|
||||
{
|
||||
|
@ -49,6 +49,12 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
static int ofs_fix;
|
||||
|
||||
CORE_ADDR
|
||||
kgdb_trgt_core_pcb(u_int cpuid)
|
||||
{
|
||||
return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb)));
|
||||
}
|
||||
|
||||
void
|
||||
kgdb_trgt_fetch_registers(int regno __unused)
|
||||
{
|
||||
|
@ -52,6 +52,18 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "kgdb.h"
|
||||
|
||||
CORE_ADDR
|
||||
kgdb_trgt_core_pcb(u_int cpuid)
|
||||
{
|
||||
CORE_ADDR addr;
|
||||
char *expr;
|
||||
|
||||
asprintf(&expr, "&cpuid_to_pcpu[%d]->pc_md.pcb", cpuid);
|
||||
addr = kgdb_parse(expr);
|
||||
free(expr);
|
||||
return (addr);
|
||||
}
|
||||
|
||||
void
|
||||
kgdb_trgt_fetch_registers(int regno __unused)
|
||||
{
|
||||
|
@ -52,6 +52,12 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "kgdb.h"
|
||||
|
||||
CORE_ADDR
|
||||
kgdb_trgt_core_pcb(u_int cpuid)
|
||||
{
|
||||
return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb)));
|
||||
}
|
||||
|
||||
void
|
||||
kgdb_trgt_fetch_registers(int regno __unused)
|
||||
{
|
||||
|
@ -49,6 +49,12 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "kgdb.h"
|
||||
|
||||
CORE_ADDR
|
||||
kgdb_trgt_core_pcb(u_int cpuid)
|
||||
{
|
||||
return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb)));
|
||||
}
|
||||
|
||||
void
|
||||
kgdb_trgt_fetch_registers(int regno __unused)
|
||||
{
|
||||
|
@ -44,6 +44,12 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "kgdb.h"
|
||||
|
||||
CORE_ADDR
|
||||
kgdb_trgt_core_pcb(u_int cpuid)
|
||||
{
|
||||
return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb)));
|
||||
}
|
||||
|
||||
void
|
||||
kgdb_trgt_fetch_registers(int regno __unused)
|
||||
{
|
||||
|
@ -46,6 +46,12 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include "kgdb.h"
|
||||
|
||||
CORE_ADDR
|
||||
kgdb_trgt_core_pcb(u_int cpuid)
|
||||
{
|
||||
return (kgdb_trgt_stop_pcb(cpuid, sizeof(struct pcb)));
|
||||
}
|
||||
|
||||
void
|
||||
kgdb_trgt_fetch_registers(int regno __unused)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user