Generic and i386 specific Haiku native and target debugger support.

The target debugger won't work though, since quite a bit of code
would need to be moved from the native support files to those for
the target support. But that's not that important at the moment, since
we're mainly want a native debugger.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12027 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2005-03-26 12:57:07 +00:00
parent 4292001718
commit ffe68e41fb
5 changed files with 1840 additions and 0 deletions

1614
src/bin/gdb/gdb/haiku-nat.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,42 @@
/* Haiku native-dependent definitions.
Copyright 2005 Ingo Weinhold <bonefish@cs.tu-berlin.de>.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef HAIKU_NAT_H
#define HAIKU_NAT_H
#include <debugger.h>
/* Required by haiku-nat.c, implemented in <arch>-haiku-nat.c. */
void haiku_supply_registers(int reg, const debug_cpu_state *cpuState);
void haiku_collect_registers(int reg, debug_cpu_state *cpuState);
struct haiku_image_info;
/* Function used by solib-haiku.c to iterate through the list of images of
the inferior.
TODO: This must go, since it works only in a native debugger. We can
probably tunnel these data through the xfer_memory() function.
*/
struct haiku_image_info *haiku_get_next_image_info(int lastID);
#endif /* HAIKU_NAT_H */

View File

@ -0,0 +1,22 @@
/* Haiku target-dependent common to multiple platforms.
Copyright 2005 Ingo Weinhold <bonefish@cs.tu-berlin.de>.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "defs.h"

View File

@ -0,0 +1,85 @@
/* Native-dependent code for Haiku i386.
Copyright 2005 Ingo Weinhold <bonefish@cs.tu-berlin.de>.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "haiku-nat.h"
#include "i386-tdep.h"
#include "i387-tdep.h"
#include "inferior.h"
#include "regcache.h"
#include "target.h"
/* Offset in `struct debug_cpu_state' where MEMBER is stored. */
#define REG_OFFSET(member) offsetof (struct debug_cpu_state, member)
/* At kHaikuI386RegOffset[REGNUM] you'll find the offset in `struct
debug_cpu_state' where the GDB register REGNUM is stored. */
static int kHaikuI386RegOffset[] = {
REG_OFFSET (eax),
REG_OFFSET (ecx),
REG_OFFSET (edx),
REG_OFFSET (ebx),
REG_OFFSET (user_esp),
REG_OFFSET (ebp),
REG_OFFSET (esi),
REG_OFFSET (edi),
REG_OFFSET (eip),
REG_OFFSET (eflags),
REG_OFFSET (cs),
REG_OFFSET (user_ss),
REG_OFFSET (ds),
REG_OFFSET (es),
REG_OFFSET (fs),
REG_OFFSET (gs)
};
void
haiku_supply_registers(int reg, const debug_cpu_state *cpuState)
{
if (reg == -1) {
int i;
for (i = 0; i < NUM_REGS; i++)
haiku_supply_registers(i, cpuState);
} else if (reg < I386_ST0_REGNUM) {
int offset = kHaikuI386RegOffset[reg];
regcache_raw_supply (current_regcache, reg, (char*)cpuState + offset);
} else {
i387_supply_fxsave (current_regcache, -1, cpuState->extended_regs);
}
}
void
haiku_collect_registers(int reg, debug_cpu_state *cpuState)
{
if (reg == -1) {
int i;
for (i = 0; i < NUM_REGS; i++)
haiku_collect_registers(i, cpuState);
} else if (reg < I386_ST0_REGNUM) {
int offset = kHaikuI386RegOffset[reg];
regcache_raw_collect (current_regcache, reg, (char*)cpuState + offset);
} else {
i387_collect_fsave (current_regcache, -1, cpuState->extended_regs);
}
}

View File

@ -0,0 +1,77 @@
/* Target-dependent code for Haiku i386.
Copyright 2005 Ingo Weinhold <bonefish@cs.tu-berlin.de>.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "gdbarch.h"
#include "i386-tdep.h"
#include "osabi.h"
//#define TRACE_I386_HAIKU_NAT
#ifdef TRACE_I386_HAIKU_NAT
#define TRACE(x) printf x
#else
#define TRACE(x) while (false) {}
#endif
static void
i386_haiku_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
// Haiku uses ELF.
i386_elf_init_abi (info, gdbarch);
// the offset of the PC in the jmp_buf structure (cf. setjmp(), longjmp())
tdep->jb_pc_offset = 20;
// TODO: Signal support.
// tdep->sigtramp_p = i386_haiku_sigtramp_p;
// tdep->sigcontext_addr = i386_haiku_sigcontext_addr;
// tdep->sc_reg_offset = i386_haiku_sc_reg_offset;
// tdep->sc_num_regs = ARRAY_SIZE (i386_haiku_sc_reg_offset);
// We don't need this at the moment. The Haiku runtime loader also relocates
// R_386_JMP_SLOT entries. No lazy resolving is done.
// set_gdbarch_skip_solib_resolver (gdbarch, haiku_skip_solib_resolver);
}
static enum gdb_osabi
i386_haiku_osabi_sniffer (bfd * abfd)
{
char *targetName = bfd_get_target (abfd);
if (strcmp (targetName, "elf32-i386") == 0)
return GDB_OSABI_HAIKU;
return GDB_OSABI_UNKNOWN;
}
void
_initialize_i386_haiku_tdep (void)
{
gdbarch_register_osabi_sniffer (bfd_arch_i386, bfd_target_elf_flavour,
i386_haiku_osabi_sniffer);
gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_HAIKU,
i386_haiku_init_abi);
}