1/* 2 * Copyright (c) 2004 Marcel Moolenaar 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 11 unchanged lines hidden (view full) --- 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/gnu/usr.bin/gdb/kgdb/trgt_i386.c 210852 2010-08-04 21:02:04Z jhb $"); |
29 30#include <sys/param.h> 31#include <sys/proc.h> 32#include <machine/pcb.h> 33#include <machine/frame.h> 34#include <machine/segments.h> 35#include <machine/tss.h> 36#include <err.h> --- 94 unchanged lines hidden (view full) --- 131 struct kthr *kt; 132 struct segment_descriptor sd; 133 uintptr_t addr, cpu0prvpage, tss; 134 135 kt = kgdb_thr_lookup_tid(ptid_get_pid(inferior_ptid)); 136 if (kt == NULL || kt->cpu == NOCPU) 137 return (0); 138 |
139 addr = kgdb_lookup("gdt"); |
140 if (addr == 0) 141 return (0); 142 addr += (kt->cpu * NGDT + GPROC0_SEL) * sizeof(sd); 143 if (kvm_read(kvm, addr, &sd, sizeof(sd)) != sizeof(sd)) { 144 warnx("kvm_read: %s", kvm_geterr(kvm)); 145 return (0); 146 } 147 if (sd.sd_type != SDT_SYS386BSY) { --- 6 unchanged lines hidden (view full) --- 154 * In SMP kernels, the TSS is stored as part of the per-CPU 155 * data. On older kernels, the CPU0's private page 156 * is stored at an address that isn't mapped in minidumps. 157 * However, the data is mapped at the alternate cpu0prvpage 158 * address. Thus, if the TSS is at the invalid address, 159 * change it to be relative to cpu0prvpage instead. 160 */ 161 if (trunc_page(tss) == 0xffc00000) { |
162 addr = kgdb_lookup("cpu0prvpage"); 163 if (addr == 0) |
164 return (0); |
165 if (kvm_read(kvm, addr, &cpu0prvpage, sizeof(cpu0prvpage)) != 166 sizeof(cpu0prvpage)) { 167 warnx("kvm_read: %s", kvm_geterr(kvm)); 168 return (0); 169 } 170 tss = cpu0prvpage + (tss & PAGE_MASK); 171 } 172 return ((CORE_ADDR)tss); --- 209 unchanged lines hidden --- |