summaryrefslogtreecommitdiff
path: root/devel/gdb/files/kgdb/i386fbsd-kern.c
blob: aefefb5a9265a819f6cd0e263bb91b2fa463eab1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
/*
 * Copyright (c) 2004 Marcel Moolenaar
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 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.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <sys/cdefs.h>

#include "defs.h"
#include "frame-unwind.h"
#include "gdbcore.h"
#include "inferior.h"
#include "osabi.h"
#include "regcache.h"
#include "progspace.h"
#include "solib.h"
#include "trad-frame.h"
#include "i386-tdep.h"

#ifdef __i386__
#include <sys/proc.h>
#include <machine/pcb.h>
#include <machine/frame.h>
#include <machine/segments.h>
#include <machine/tss.h>
#endif

#include "kgdb.h"

struct i386fbsd_info {
	int ofs_fix;
};

/* Per-program-space data key.  */
static const struct program_space_data *i386fbsd_pspace_data;

static void
i386fbsd_pspace_data_cleanup (struct program_space *pspace, void *arg)
{
  struct i386fbsd_info *info = (struct i386fbsd_info *)arg;

  xfree (info);
}

/* Get the current i386fbsd data.  If none is found yet, add it now.  This
   function always returns a valid object.  */

static struct i386fbsd_info *
get_i386fbsd_info (void)
{
  struct i386fbsd_info *info;

  info = (struct i386fbsd_info *)
    program_space_data (current_program_space, i386fbsd_pspace_data);
  if (info != NULL)
    return info;

  info = XCNEW (struct i386fbsd_info);
  set_program_space_data (current_program_space, i386fbsd_pspace_data, info);

  /*
   * In revision 1.117 of i386/i386/exception.S trap handlers
   * were changed to pass trapframes by reference rather than
   * by value.  Detect this by seeing if the first instruction
   * at the 'calltrap' label is a "push %esp" which has the
   * opcode 0x54.
   */
  if (parse_and_eval_long("((char *)calltrap)[0]") == 0x54)
    info->ofs_fix = 4;
  else
    info->ofs_fix = 0;
  return info;
}

/*
 * Even though the pcb contains fields for the segment selectors, only
 * %gs is updated on each context switch.  The other selectors are
 * saved in stoppcbs[], but we just hardcode their known values rather
 * than handling that special case.
 */
static const int i386fbsd_pcb_offset[] = {
  -1,				/* %eax */
  -1,				/* %ecx */
  -1,				/* %edx */
  4 * 4,			/* %ebx */
  3 * 4,			/* %esp */
  2 * 4,			/* %ebp */
  1 * 4,			/* %esi */
  0 * 4,			/* %edi */
  5 * 4,			/* %eip */
  -1,				/* %eflags */
  -1,				/* %cs */
  -1,				/* %ss */
  -1,				/* %ds */
  -1,				/* %es */
  -1,				/* %fs */
  -1,				/* %gs */
};

#define	CODE_SEL	(4 << 3)
#define	DATA_SEL	(5 << 3)
#define	PRIV_SEL	(1 << 3)

static void
i386fbsd_supply_pcb(struct regcache *regcache, CORE_ADDR pcb_addr)
{
  gdb_byte buf[4];
  int i;

  memset(buf, 0, sizeof(buf));

  /*
   * XXX The PCB may have been swapped out.  Supply a dummy %eip value
   * so as to avoid triggering an exception during stack unwinding.
   */
  regcache->raw_supply(I386_EIP_REGNUM, buf);
  for (i = 0; i < ARRAY_SIZE (i386fbsd_pcb_offset); i++)
    if (i386fbsd_pcb_offset[i] != -1) {
      if (target_read_memory(pcb_addr + i386fbsd_pcb_offset[i], buf, sizeof buf)
	  != 0)
	continue;
      regcache->raw_supply(i, buf);
    }
  regcache->raw_supply_unsigned(I386_CS_REGNUM, CODE_SEL);
  regcache->raw_supply_unsigned(I386_DS_REGNUM, DATA_SEL);
  regcache->raw_supply_unsigned(I386_ES_REGNUM, DATA_SEL);
  regcache->raw_supply_unsigned(I386_FS_REGNUM, PRIV_SEL);
  regcache->raw_supply_unsigned(I386_GS_REGNUM, DATA_SEL);
  regcache->raw_supply_unsigned(I386_SS_REGNUM, DATA_SEL);
}

#ifdef __i386__
/* TODO: Make this cross-debugger friendly. */
static const int i386fbsd_tss_offset[] = {
  10 * 4,			/* %eax */
  11 * 4,			/* %ecx */
  12 * 4,			/* %edx */
  13 * 4,			/* %ebx */
  14 * 4,			/* %esp */
  15 * 4,			/* %ebp */
  16 * 4,			/* %esi */
  17 * 4,			/* %edi */
  8 * 4,			/* %eip */
  9 * 4,			/* %eflags */
  19 * 4,			/* %cs */
  20 * 4,			/* %ss */
  21 * 4,			/* %ds */
  18 * 4,			/* %es */
  22 * 4,			/* %fs */
  23 * 4,			/* %gs */
};

/*
 * If the current thread is executing on a CPU, fetch the common_tss
 * for that CPU.
 *
 * This is painful because 'struct pcpu' is variant sized, so we can't
 * use it.  Instead, we lookup the GDT selector for this CPU and
 * extract the base of the TSS from there.
 */
static CORE_ADDR
i386fbsd_fetch_tss(void)
{
	struct kthr *kt;
	struct segment_descriptor sd;
	CORE_ADDR addr, cpu0prvpage, tss;

	kt = kgdb_thr_lookup_tid(inferior_ptid.tid());
	if (kt == NULL || kt->cpu == NOCPU || kt->cpu < 0)
		return (0);

	addr = kgdb_lookup("gdt");
	if (addr == 0)
		return (0);
	addr += (kt->cpu * NGDT + GPROC0_SEL) * sizeof(sd);
	if (target_read_memory(addr, (gdb_byte *)&sd, sizeof(sd)) != 0)
		return (0);
	if (sd.sd_type != SDT_SYS386BSY) {
		warning ("descriptor is not a busy TSS");
		return (0);
	}
	tss = sd.sd_hibase << 24 | sd.sd_lobase;

	/*
	 * In SMP kernels, the TSS is stored as part of the per-CPU
	 * data.  On older kernels, the CPU0's private page
	 * is stored at an address that isn't mapped in minidumps.
	 * However, the data is mapped at the alternate cpu0prvpage
	 * address.  Thus, if the TSS is at the invalid address,
	 * change it to be relative to cpu0prvpage instead.
	 */ 
	if (trunc_page(tss) == 0xffc00000) {
		try {
			cpu0prvpage = parse_and_eval_address("cpu0prvpage");
		} catch (const gdb_exception_error &e) {
			return (0);
		}
		tss = cpu0prvpage + (tss & PAGE_MASK);
	}
	return (tss);
}

static struct trad_frame_cache *
i386fbsd_dblfault_cache (struct frame_info *this_frame, void **this_cache)
{
  struct gdbarch *gdbarch = get_frame_arch (this_frame);
  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
  struct trad_frame_cache *cache;
  CORE_ADDR addr, func, tss;
  int i;

  if (*this_cache != NULL)
    return (struct trad_frame_cache *)(*this_cache);

  cache = trad_frame_cache_zalloc (this_frame);
  *this_cache = cache;

  func = get_frame_func (this_frame);
  tss = i386fbsd_fetch_tss ();

  for (i = 0; i < ARRAY_SIZE (i386fbsd_tss_offset); i++)
    if (i386fbsd_tss_offset[i] != -1)
      trad_frame_set_reg_addr (cache, i, tss + i386fbsd_tss_offset[i]);

  /* Construct the frame ID using the function start.  */
  /* XXX: Stack address should be dbfault_stack + PAGE_SIZE. */
  trad_frame_set_id (cache, frame_id_build (tss + sizeof(struct i386tss),
					    func));

  return cache;
}

static void
i386fbsd_dblfault_this_id (struct frame_info *this_frame,
			     void **this_cache, struct frame_id *this_id)
{
  struct trad_frame_cache *cache =
    i386fbsd_dblfault_cache (this_frame, this_cache);
  
  trad_frame_get_id (cache, this_id);
}

static struct value *
i386fbsd_dblfault_prev_register (struct frame_info *this_frame,
				   void **this_cache, int regnum)
{
  struct trad_frame_cache *cache =
    i386fbsd_dblfault_cache (this_frame, this_cache);

  return trad_frame_get_register (cache, this_frame, regnum);
}

static int
i386fbsd_dblfault_sniffer (const struct frame_unwind *self,
			     struct frame_info *this_frame,
			     void **this_prologue_cache)
{
  const char *name;

  find_pc_partial_function (get_frame_func (this_frame), &name, NULL, NULL);
  return (name && strcmp (name, "dblfault_handler") == 0);
}

static const struct frame_unwind i386fbsd_dblfault_unwind = {
  SIGTRAMP_FRAME,
  default_frame_unwind_stop_reason,
  i386fbsd_dblfault_this_id,
  i386fbsd_dblfault_prev_register,
  NULL,
  i386fbsd_dblfault_sniffer
};
#endif

static const int i386fbsd_trapframe_offset[] = {
  10 * 4,			/* %eax */
  9 * 4,			/* %ecx */
  8 * 4,			/* %edx */
  7 * 4,			/* %ebx */
  16 * 4,			/* %esp */
  5 * 4,			/* %ebp */
  4 * 4,			/* %esi */
  3 * 4,			/* %edi */
  13 * 4,			/* %eip */
  15 * 4,			/* %eflags */
  14 * 4,			/* %cs */
  17 * 4,			/* %ss */
  2 * 4,			/* %ds */
  1 * 4,			/* %es */
  0 * 4,			/* %fs */
  -1				/* %gs */
};

#define	TRAPFRAME_SIZE		72

static struct trad_frame_cache *
i386fbsd_trapframe_cache (struct frame_info *this_frame, void **this_cache)
{
  struct gdbarch *gdbarch = get_frame_arch (this_frame);
  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
  struct trad_frame_cache *cache;
  struct i386fbsd_info *info;
  CORE_ADDR addr, cs, func, pc, sp;
  const char *name;
  int i;

  if (*this_cache != NULL)
    return ((struct trad_frame_cache *)*this_cache);

  info = get_i386fbsd_info();
  cache = trad_frame_cache_zalloc (this_frame);
  *this_cache = cache;

  func = get_frame_func (this_frame);
  sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM);

  find_pc_partial_function (func, &name, NULL, NULL);
  if (strcmp(name, "calltrap") == 0 ||
      strcmp(name, "Xlcall_syscall") == 0 ||
      strcmp(name, "Xint0x80_syscall") == 0)
    /* Traps in later kernels pass the trap frame by reference. */
    sp += info->ofs_fix;
  else if (strcmp(name, "Xtimerint") == 0)
    /* Timer interrupts also pass the trap frame by reference. */
    sp += info->ofs_fix;
  else if (strcmp(name, "Xcpustop") == 0 ||
	   strcmp(name, "Xrendezvous") == 0 ||
	   strcmp(name, "Xipi_intr_bitmap_handler") == 0 ||
	   strcmp(name, "Xlazypmap") == 0)
    /* These handlers push a trap frame only. */
    ;
  else if (strcmp(name, "fork_trampoline") == 0)
    if (get_frame_pc (this_frame) == func)
      {
	/* fork_exit hasn't been called (kthread has never run), so
	   %esp in the pcb points to the word above the trapframe.  */
	sp += 4;
      }
    else
      {
	/* fork_exit has been called, so %esp in fork_exit's
	   frame is &tf - 12.  */
	sp += 12;
      }
  else {
    /* Interrupt frames pass the IDT vector in addition to the trap frame. */
    sp += info->ofs_fix + 4;
  }

  addr = sp + i386fbsd_trapframe_offset[I386_CS_REGNUM];
  cs = read_memory_unsigned_integer (addr, 4, byte_order);
  for (i = 0; i < ARRAY_SIZE (i386fbsd_trapframe_offset); i++)
    {
      /* %ss/%esp are only present in the trapframe for a trap from
          userland.  */
      if ((cs & I386_SEL_RPL) == I386_SEL_KPL)
	{
	  if (i == I386_SS_REGNUM)
	    continue;
	  if (i == I386_ESP_REGNUM)
	    {
	      trad_frame_set_reg_value (cache, i, sp + TRAPFRAME_SIZE - 8);
	      continue;
	    }
	}
      if (i386fbsd_trapframe_offset[i] != -1)
	trad_frame_set_reg_addr (cache, i, sp + i386fbsd_trapframe_offset[i]);
    }

  /* Read %eip from trap frame.  */
  addr = sp + i386fbsd_trapframe_offset[I386_EIP_REGNUM];
  pc = read_memory_unsigned_integer (addr, 4, byte_order);

  if (pc == 0 && strcmp(name, "fork_trampoline") == 0)
    {
      /* Initial frame of a kthread; terminate backtrace.  */
      trad_frame_set_id (cache, outer_frame_id);
    }
  else
    {
      /* Construct the frame ID using the function start.  */
      sp += TRAPFRAME_SIZE;
      if ((cs & I386_SEL_RPL) == I386_SEL_KPL)
	sp -= 8;
      trad_frame_set_id (cache, frame_id_build (sp, func));
    }

  return cache;
}

static void
i386fbsd_trapframe_this_id (struct frame_info *this_frame,
			     void **this_cache, struct frame_id *this_id)
{
  struct trad_frame_cache *cache =
    i386fbsd_trapframe_cache (this_frame, this_cache);
  
  trad_frame_get_id (cache, this_id);
}

static struct value *
i386fbsd_trapframe_prev_register (struct frame_info *this_frame,
				   void **this_cache, int regnum)
{
  struct trad_frame_cache *cache =
    i386fbsd_trapframe_cache (this_frame, this_cache);

  return trad_frame_get_register (cache, this_frame, regnum);
}

static int
i386fbsd_trapframe_sniffer (const struct frame_unwind *self,
			     struct frame_info *this_frame,
			     void **this_prologue_cache)
{
  const char *name;

  find_pc_partial_function (get_frame_func (this_frame), &name, NULL, NULL);
  return (name && ((strcmp (name, "calltrap") == 0)
		   || (strcmp (name, "fork_trampoline") == 0)
		   || (name[0] == 'X' && name[1] != '_')));
}

static const struct frame_unwind i386fbsd_trapframe_unwind = {
  SIGTRAMP_FRAME,
  default_frame_unwind_stop_reason,
  i386fbsd_trapframe_this_id,
  i386fbsd_trapframe_prev_register,
  NULL,
  i386fbsd_trapframe_sniffer
};

static void
i386fbsd_kernel_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
{

	i386_elf_init_abi(info, gdbarch);

#ifdef __i386__
	frame_unwind_prepend_unwinder(gdbarch, &i386fbsd_dblfault_unwind);
#endif
	frame_unwind_prepend_unwinder(gdbarch, &i386fbsd_trapframe_unwind);

	set_solib_ops(gdbarch, &kld_so_ops);

	fbsd_vmcore_set_supply_pcb(gdbarch, i386fbsd_supply_pcb);
	fbsd_vmcore_set_cpu_pcb_addr(gdbarch, kgdb_trgt_stop_pcb);
}

void _initialize_i386_kgdb_tdep(void);
void
_initialize_i386_kgdb_tdep(void)
{
	/* This is used for both i386 and amd64, but amd64 always
	   includes this target, so just include it here.  */
	gdbarch_register_osabi_sniffer(bfd_arch_i386,
				       bfd_target_elf_flavour,
				       fbsd_kernel_osabi_sniffer);
	gdbarch_register_osabi (bfd_arch_i386, 0,
	    GDB_OSABI_FREEBSD_KERNEL, i386fbsd_kernel_init_abi);

	i386fbsd_pspace_data = register_program_space_data_with_cleanup (NULL,
	    i386fbsd_pspace_data_cleanup);

#ifdef __i386__
	/*
	 * FreeBSD/i386 kernels prior to the introduction of AVX
	 * support used a different layout for the PCB.  If gdb is
	 * compiled on these systems, these asserts will fail.  The
	 * package builders build packages on older systems which are
	 * then run on newer systems.  These binaries trip over these
	 * assertions even when debugging user programs and even
	 * though the running kernel is new enough.  To cope, disable
	 * the assertion checks unless gdb is built against a new
	 * enough world.  Note that this means kgdb is not going to
	 * parse PCBs correctly on FreeBSD/i386 kernels before AVX was
	 * merged.
	 */
#if __FreeBSD_version >= 1001505
	gdb_assert(offsetof(struct pcb, pcb_ebx)
		   == i386fbsd_pcb_offset[I386_EBX_REGNUM]);
	gdb_assert(offsetof(struct pcb, pcb_esp)
		   == i386fbsd_pcb_offset[I386_ESP_REGNUM]);
	gdb_assert(offsetof(struct pcb, pcb_ebp)
		   == i386fbsd_pcb_offset[I386_EBP_REGNUM]);
	gdb_assert(offsetof(struct pcb, pcb_esi)
		   == i386fbsd_pcb_offset[I386_ESI_REGNUM]);
	gdb_assert(offsetof(struct pcb, pcb_edi)
		   == i386fbsd_pcb_offset[I386_EDI_REGNUM]);
	gdb_assert(offsetof(struct pcb, pcb_eip)
		   == i386fbsd_pcb_offset[I386_EIP_REGNUM]);
#endif
	gdb_assert(CODE_SEL == GSEL(GCODE_SEL, SEL_KPL));
	gdb_assert(DATA_SEL == GSEL(GDATA_SEL, SEL_KPL));
	gdb_assert(PRIV_SEL == GSEL(GPRIV_SEL, SEL_KPL));
	gdb_assert(sizeof(struct trapframe) == TRAPFRAME_SIZE);
	gdb_assert(offsetof(struct trapframe, tf_eax)
		   == i386fbsd_trapframe_offset[I386_EAX_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_ecx)
		   == i386fbsd_trapframe_offset[I386_ECX_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_edx)
		   == i386fbsd_trapframe_offset[I386_EDX_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_ebx)
		   == i386fbsd_trapframe_offset[I386_EBX_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_esp)
		   == i386fbsd_trapframe_offset[I386_ESP_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_ebp)
		   == i386fbsd_trapframe_offset[I386_EBP_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_esi)
		   == i386fbsd_trapframe_offset[I386_ESI_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_edi)
		   == i386fbsd_trapframe_offset[I386_EDI_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_eip)
		   == i386fbsd_trapframe_offset[I386_EIP_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_eflags)
		   == i386fbsd_trapframe_offset[I386_EFLAGS_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_cs)
		   == i386fbsd_trapframe_offset[I386_CS_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_ss)
		   == i386fbsd_trapframe_offset[I386_SS_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_ds)
		   == i386fbsd_trapframe_offset[I386_DS_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_es)
		   == i386fbsd_trapframe_offset[I386_ES_REGNUM]);
	gdb_assert(offsetof(struct trapframe, tf_fs)
		   == i386fbsd_trapframe_offset[I386_FS_REGNUM]);

	gdb_assert(offsetof(struct i386tss, tss_eax)
		   == i386fbsd_tss_offset[I386_EAX_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_ecx)
		   == i386fbsd_tss_offset[I386_ECX_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_edx)
		   == i386fbsd_tss_offset[I386_EDX_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_ebx)
		   == i386fbsd_tss_offset[I386_EBX_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_esp)
		   == i386fbsd_tss_offset[I386_ESP_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_ebp)
		   == i386fbsd_tss_offset[I386_EBP_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_esi)
		   == i386fbsd_tss_offset[I386_ESI_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_edi)
		   == i386fbsd_tss_offset[I386_EDI_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_eip)
		   == i386fbsd_tss_offset[I386_EIP_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_eflags)
		   == i386fbsd_tss_offset[I386_EFLAGS_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_cs)
		   == i386fbsd_tss_offset[I386_CS_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_ss)
		   == i386fbsd_tss_offset[I386_SS_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_ds)
		   == i386fbsd_tss_offset[I386_DS_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_es)
		   == i386fbsd_tss_offset[I386_ES_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_fs)
		   == i386fbsd_tss_offset[I386_FS_REGNUM]);
	gdb_assert(offsetof(struct i386tss, tss_gs)
		   == i386fbsd_tss_offset[I386_GS_REGNUM]);
#endif
}