This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re:RFA - Updated PATCH - Support H8/300H and H8S Normal Mode for GDB


Somehow earlier email did not reach the list.

Hi,

Please find updated patches which includes comments of Corinna Vinschen.

( http://sources.redhat.com/ml/gdb-patches/2003-09/msg00470.html )

>> Do you have an FSF copyright assignment?

Yes. I do have copyright assignment in place.

OK to apply ?

Regards,

Shrinivas

=====================================================================

Changelog:

2003-09-24 Shrinivas Atre <shrinivasa@KPITCummins.com>

* bfd/coff-h8300.c (funcvec_hash_newfunc): Handle normal mode

(h8300_reloc16_extra_cases) : Ditto

(h8300_bfd_link_add_symbols) : Ditto

* gdb/config/h8300/tm-h8300.h : Addition of extern variable
h8300_normal_mode

* gdb/h8300-tdep.c (BINWORD): Update BINWORD for h8300_normal_mode

(h8300_examine_prologue): Use h8300_normal_mode flag

(h8300_gdbarch_init): Set architecture info for normal mode

* sim/h8300/compile.c : Addition of extern variable h8300_normal_mode

(SP) : Handle normal mode

(bitfrom) : Use normal mode flag to return suitable value

(lvalue) : Use normal mode flag to return command line location

(decode) : Decode instruction correctly for normal mode

(init_pointers) : Initialise memory correctly for normal mode

(sim_resume) : Handle cases for normal mode using h8300_normal_mode flag

(sim_store_register) : Handle 2 byte PC for normal mode

(sim_fetch_register) : Handle 2 byte PC for normal mode

(set_h8300h) : Set normal mode flag as per architechture

(sim_load) : Allocate 64K for normal mode instead of bigger memory

=====================================================================

--- src/bfd/coff-h8300.c.orig Mon Sep 15 14:14:58 2003

+++ src/bfd/coff-h8300.c Mon Sep 15 14:10:22 2003

@@ -154,7 +154,9 @@ funcvec_hash_newfunc (struct bfd_hash_en

/* Bump the offset at which we store entries in the function

vector. We'd like to bump up the size of the vectors section,

but it's not easily available here. */

- if (bfd_get_mach (table->abfd) == bfd_mach_h8300)

+ if (bfd_get_mach (table->abfd) == bfd_mach_h8300

+ || bfd_get_mach (table->abfd) == bfd_mach_h8300hn

+ || bfd_get_mach (table->abfd) == bfd_mach_h8300sn)

table->offset += 2;

else if (bfd_get_mach (table->abfd) == bfd_mach_h8300h

|| bfd_get_mach (table->abfd) == bfd_mach_h8300s)

@@ -1124,7 +1126,9 @@ h8300_reloc16_extra_cases (bfd *abfd, st

src_address++;


/* Now create an entry in the function vector itself. */

- if (bfd_get_mach (input_section->owner) == bfd_mach_h8300)

+ if (bfd_get_mach (input_section->owner) == bfd_mach_h8300

+ || bfd_get_mach (input_section->owner) == bfd_mach_h8300hn

+ || bfd_get_mach (input_section->owner) == bfd_mach_h8300sn)

bfd_put_16 (abfd,

bfd_coff_reloc16_get_value (reloc,

link_info,

@@ -1304,7 +1308,9 @@ h8300_bfd_link_add_symbols (bfd *abfd, s


/* Bump the size of the vectors section. Each vector

takes 2 bytes on the h8300 and 4 bytes on the h8300h. */

- if (bfd_get_mach (abfd) == bfd_mach_h8300)

+ if (bfd_get_mach (abfd) == bfd_mach_h8300

+ || bfd_get_mach (abfd) == bfd_mach_h8300hn

+ || bfd_get_mach (abfd) == bfd_mach_h8300sn)

htab->vectors_sec->_raw_size += 2;

else if (bfd_get_mach (abfd) == bfd_mach_h8300h

|| bfd_get_mach (abfd) == bfd_mach_h8300s)

--------------------------------------------------------------------------

--- src/gdb/config/h8300/tm-h8300.org.h Tue Sep 23 18:22:19 2003

+++ src/gdb/config/h8300/tm-h8300.h Wed Sep 24 13:48:48 2003

@@ -26,6 +26,7 @@

GDB_TARGET_IS_H8300 in remote-e7000.c */

extern int h8300hmode;

extern int h8300smode;

+extern int h8300_normal_mode; /* 1 - Normal Mode , 0 - Advanced mode */

extern int h8300sxmode;

#define GDB_TARGET_IS_H8300


--------------------------------------------------------------------------

--- src/gdb/h8300-tdep.org.c Wed Sep 24 14:02:13 2003

+++ src/gdb/h8300-tdep.c Wed Sep 24 14:01:05 2003

@@ -49,7 +49,7 @@ enum

h8300h_reg_size = 4,

h8300_max_reg_size = 4,

};

-#define BINWORD (h8300hmode ? h8300h_reg_size : h8300_reg_size)

+#define BINWORD (h8300hmode && 0 == h8300_normal_mode ? h8300h_reg_size :
h8300_reg_size)


enum gdb_regnum

{

@@ -350,7 +350,7 @@ h8300_examine_prologue (CORE_ADDR ip, CO

}


/* If the PC isn't valid, quit now. */

- if (ip == 0 || ip & (h8300hmode ? ~0xffffff : ~0xffff))

+ if (ip == 0 || ip & (h8300hmode && 0 == h8300_normal_mode ? ~0xffffff :
~0xffff))

return 0;


next_ip = h8300_next_prologue_insn (ip, limit, &insn_word);

@@ -1220,8 +1220,18 @@ h8300_gdbarch_init (struct gdbarch_info

set_gdbarch_dwarf2_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);

set_gdbarch_stab_reg_to_regnum (gdbarch, h8300_dbg_reg_to_regnum);

set_gdbarch_register_name (gdbarch, h8300_register_name);

- set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

- set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

+ if(info.bfd_arch_info->mach != bfd_mach_h8300hn)

+ {

+ h8300_normal_mode = 0;

+ set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

+ set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

+ }

+ else

+ {

+ h8300_normal_mode = 1;

+ set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);

+ set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);

+ }

set_gdbarch_extract_return_value (gdbarch, h8300h_extract_return_value);

set_gdbarch_store_return_value (gdbarch, h8300h_store_return_value);

set_gdbarch_print_insn (gdbarch, print_insn_h8300h);

@@ -1238,8 +1248,18 @@ h8300_gdbarch_init (struct gdbarch_info

set_gdbarch_dwarf2_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);

set_gdbarch_stab_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);

set_gdbarch_register_name (gdbarch, h8300s_register_name);

- set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

- set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

+ if(info.bfd_arch_info->mach != bfd_mach_h8300sn)

+ {

+ h8300_normal_mode = 0;

+ set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

+ set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

+ }

+ else

+ {

+ h8300_normal_mode = 1;

+ set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);

+ set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);

+ }

set_gdbarch_extract_return_value (gdbarch, h8300h_extract_return_value);

set_gdbarch_store_return_value (gdbarch, h8300h_store_return_value);

set_gdbarch_print_insn (gdbarch, print_insn_h8300s);

@@ -1256,8 +1276,18 @@ h8300_gdbarch_init (struct gdbarch_info

set_gdbarch_dwarf2_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);

set_gdbarch_stab_reg_to_regnum (gdbarch, h8300s_dbg_reg_to_regnum);

set_gdbarch_register_name (gdbarch, h8300sx_register_name);

- set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

- set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

+ if(info.bfd_arch_info->mach != bfd_mach_h8300sxn)

+ {

+ h8300_normal_mode = 0;

+ set_gdbarch_ptr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

+ set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);

+ }

+ else

+ {

+ h8300_normal_mode = 1;

+ set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);

+ set_gdbarch_addr_bit (gdbarch, 2 * TARGET_CHAR_BIT);

+ }

set_gdbarch_extract_return_value (gdbarch, h8300h_extract_return_value);

set_gdbarch_store_return_value (gdbarch, h8300h_store_return_value);

set_gdbarch_print_insn (gdbarch, print_insn_h8300s);

--------------------------------------------------------------------------

--- src/sim/h8300/compile.org.c Wed Sep 24 14:03:24 2003

+++ src/sim/h8300/compile.c Wed Sep 24 14:04:12 2003

@@ -53,7 +53,7 @@ static void set_simcache_size (SIM_DESC,


#define X(op, size) (op * 4 + size)


-#define SP (h8300hmode ? SL : SW)

+#define SP (h8300hmode && 0 == h8300_normal_mode ? SL : SW)


#define h8_opcodes ops

#define DEFINE_TABLE

@@ -510,6 +510,7 @@ enum { POLL_QUIT_INTERVAL = 0x80000 };


int h8300hmode = 0;

int h8300smode = 0;

+int h8300_normal_mode = 0;

int h8300sxmode = 0;


static int memory_size;

@@ -539,7 +540,7 @@ bitfrom (int x)

case L_32:

return SL;

case L_P:

- return h8300hmode ? SL : SW;

+ return (h8300hmode && 0 == h8300_normal_mode)? SL : SW;

}

return 0;

}

@@ -575,9 +576,9 @@ lvalue (SIM_DESC sd, int x, int rn, unsi

static int

cmdline_location()

{

- if (h8300smode)

+ if (h8300smode && 0 == h8300_normal_mode)

return 0xffff00L;

- else if (h8300hmode)

+ else if (h8300hmode && 0 == h8300_normal_mode)

return 0x2ff00L;

else

return 0xff00L;

@@ -837,8 +838,10 @@ decode (SIM_DESC sd, int addr, unsigned

}

else if ((looking_for & MODE) == VECIND)

{

- /* FIXME: Multiplier should be 2 for "normal" mode. */

- cst[opnum] = ((data[1] & 0x7f) + 0x80) * 4;

+ if(h8300_normal_mode)

+ cst[opnum] = ((data[1] & 0x7f) + 0x80) * 2;

+ else

+ cst[opnum] = ((data[1] & 0x7f) + 0x80) * 4;

cst[opnum] += h8_get_vbr (sd); /* Add vector base reg. */

}

else if ((looking_for & SIZE) == L_32)

@@ -1774,9 +1777,9 @@ init_pointers (SIM_DESC sd)


littleendian.i = 1;


- if (h8300smode)

+ if (h8300smode && 0 == h8300_normal_mode)

memory_size = H8300S_MSIZE;

- else if (h8300hmode)

+ else if (h8300hmode && 0 == h8300_normal_mode)

memory_size = H8300H_MSIZE;

else

memory_size = H8300_MSIZE;

@@ -1950,7 +1953,7 @@ sim_resume (SIM_DESC sd, int step, int s

}


oldmask = h8_get_mask (sd);

- if (!h8300hmode)

+ if (!h8300hmode || h8300_normal_mode)

h8_set_mask (sd, 0xffff);

do

{

@@ -2790,7 +2793,7 @@ sim_resume (SIM_DESC sd, int step, int s


/* Setting char_ptr_size to the sizeof (char *) on the different

architectures. */

- if (h8300hmode || h8300smode)

+ if ((h8300hmode || h8300smode) && 0 == h8300_normal_mode)

{

char_ptr_size = 4;

}

@@ -2859,7 +2862,7 @@ sim_resume (SIM_DESC sd, int step, int s

for (i = 0; i < no_of_args; i++)

{

/* Saving the argv pointer. */

- if (h8300hmode || h8300smode)

+ if ((h8300hmode || h8300smode) && 0 == h8300_normal_mode)

{

SET_MEMORY_L (argv_ptrs_location, argv_ptrs[i]);

}

@@ -2875,7 +2878,7 @@ sim_resume (SIM_DESC sd, int step, int s


/* Required by POSIX, Setting 0x0 at the end of the list of argv

pointers. */

- if (h8300hmode || h8300smode)

+ if ((h8300hmode || h8300smode) && 0 == h8300_normal_mode)

{

SET_MEMORY_L (old_sp, 0x0);

}

@@ -2914,7 +2917,7 @@ sim_resume (SIM_DESC sd, int step, int s


/* Setting filename_ptr to first argument of open, */

/* and trying to get mode. */

- if (h8300sxmode || h8300hmode || h8300smode)

+ if ((h8300sxmode || h8300hmode || h8300smode) && 0 == h8300_normal_mode)

{

filename_ptr = GET_L_REG (0);

mode = GET_MEMORY_L (h8_get_reg (sd, SP_REGNUM) + 4);

@@ -2965,8 +2968,8 @@ sim_resume (SIM_DESC sd, int step, int s

int read_return = 0; /* Return value from callback to

read. */


- fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);

- buf_size = h8300hmode ? GET_L_REG (2) : GET_W_REG (2);

+ fd = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (0) : GET_W_REG
(0);

+ buf_size = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (2) :
GET_W_REG (2);


char_ptr = (char *) malloc (sizeof (char) * buf_size);


@@ -3000,9 +3003,9 @@ sim_resume (SIM_DESC sd, int step, int s

int write_return; /* Return value from callback to write. */

int i = 0; /* Loop counter */


- fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);

- char_ptr = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);

- len = h8300hmode ? GET_L_REG (2) : GET_W_REG (2);

+ fd = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (0) : GET_W_REG
(0);

+ char_ptr = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (1) :
GET_W_REG (1);

+ len = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (2) : GET_W_REG
(2);


/* Allocating space for the characters to be written. */

ptr = (char *) malloc (sizeof (char) * len);

@@ -3032,9 +3035,9 @@ sim_resume (SIM_DESC sd, int step, int s

int origin; /* Origin */

int lseek_return; /* Return value from callback to lseek. */


- fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);

- offset = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);

- origin = h8300hmode ? GET_L_REG (2) : GET_W_REG (2);

+ fd = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (0) : GET_W_REG
(0);

+ offset = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (1) :
GET_W_REG (1);

+ origin = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (2) :
GET_W_REG (2);


/* Callback lseek and return offset. */

lseek_return =

@@ -3050,7 +3053,7 @@ sim_resume (SIM_DESC sd, int step, int s

int fd; /* File descriptor */

int close_return; /* Return value from callback to close. */


- fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);

+ fd = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (0) : GET_W_REG
(0);


/* Callback close and return. */

close_return = sim_callback->close (sim_callback, fd);

@@ -3068,10 +3071,10 @@ sim_resume (SIM_DESC sd, int step, int s

int stat_ptr; /* Pointer to stat record. */

char *temp_stat_ptr; /* Temporary stat_rec pointer. */


- fd = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);

+ fd = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (0) : GET_W_REG
(0);


/* Setting stat_ptr to second argument of stat. */

- stat_ptr = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);

+ stat_ptr = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (1) :
GET_W_REG (1);


/* Callback stat and return. */

fstat_return = sim_callback->fstat (sim_callback, fd, &stat_rec);

@@ -3120,7 +3123,7 @@ sim_resume (SIM_DESC sd, int step, int s

int i = 0; /* Loop Counter */


/* Setting filename_ptr to first argument of open. */

- filename_ptr = h8300hmode ? GET_L_REG (0) : GET_W_REG (0);

+ filename_ptr = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (0) :
GET_W_REG (0);


/* Trying to find the length of the filename. */

temp_char = GET_MEMORY_B (h8_get_reg (sd, 0));

@@ -3144,7 +3147,7 @@ sim_resume (SIM_DESC sd, int step, int s


/* Setting stat_ptr to second argument of stat. */

/* stat_ptr = h8_get_reg (sd, 1); */

- stat_ptr = h8300hmode ? GET_L_REG (1) : GET_W_REG (1);

+ stat_ptr = (h8300hmode && 0 == h8300_normal_mode) ? GET_L_REG (1) :
GET_W_REG (1);


/* Callback stat and return. */

stat_return =

@@ -3552,7 +3555,7 @@ sim_resume (SIM_DESC sd, int step, int s

call:

tmp = h8_get_reg (sd, SP_REGNUM);


- if (h8300hmode)

+ if (h8300hmode && 0 == h8300_normal_mode)

{

tmp -= 4;

SET_MEMORY_L (tmp, code->next_pc);

@@ -3584,7 +3587,7 @@ sim_resume (SIM_DESC sd, int step, int s

h8_set_exr (sd, GET_MEMORY_L (tmp));

tmp += 4;

}

- if (h8300hmode)

+ if (h8300hmode && 0 == h8300_normal_mode)

{

h8_set_ccr (sd, GET_MEMORY_L (tmp));

tmp += 4;

@@ -3607,7 +3610,7 @@ sim_resume (SIM_DESC sd, int step, int s

rts:

tmp = h8_get_reg (sd, SP_REGNUM);


- if (h8300hmode)

+ if (h8300hmode && 0 == h8300_normal_mode)

{

pc = GET_MEMORY_L (tmp);

tmp += 4;

@@ -3658,10 +3661,20 @@ sim_resume (SIM_DESC sd, int step, int s

goto end; /* res is vector number. */


tmp = h8_get_reg (sd, SP_REGNUM);

- tmp -= 4;

- SET_MEMORY_L (tmp, code->next_pc);

- tmp -= 4;

- SET_MEMORY_L (tmp, h8_get_ccr (sd));

+ if(h8300_normal_mode)

+ {

+ tmp -= 2;

+ SET_MEMORY_W (tmp, code->next_pc);

+ tmp -= 2;

+ SET_MEMORY_W (tmp, h8_get_ccr (sd));

+ }

+ else

+ {

+ tmp -= 4;

+ SET_MEMORY_L (tmp, code->next_pc);

+ tmp -= 4;

+ SET_MEMORY_L (tmp, h8_get_ccr (sd));

+ }

intMaskBit = 1;

BUILDSR (sd);


@@ -3673,8 +3686,10 @@ sim_resume (SIM_DESC sd, int step, int s


h8_set_reg (sd, SP_REGNUM, tmp);


- /* FIXME: "normal" mode should use 2-byte ptrs. */

- pc = GET_MEMORY_L (0x20 + res * 4);

+ if(h8300_normal_mode)

+ pc = GET_MEMORY_L (0x10 + res * 2); /* Vector addresses are 0x10,0x12,0x14
and 0x16 */

+ else

+ pc = GET_MEMORY_L (0x20 + res * 4);

goto end;


case O (O_BPT, SN):

@@ -4703,7 +4718,10 @@ sim_store_register (SIM_DESC sd, int rn,

switch (rn)

{

case PC_REGNUM:

- h8_set_pc (sd, intval);

+ if(h8300_normal_mode)

+ h8_set_pc (sd, shortval); /* PC for Normal mode is 2 bytes */

+ else

+ h8_set_pc (sd, intval);

break;

default:

(*sim_callback->printf_filtered) (sim_callback,

@@ -4814,7 +4832,8 @@ sim_fetch_register (SIM_DESC sd, int rn,

longreg = 1;

break;

}

- if (h8300hmode || longreg)

+ /* In Normal mode PC is 2 byte, but other registers are 4 byte */

+ if ((h8300hmode || longreg) && !(rn == PC_REGNUM && h8300_normal_mode))

{

buf[0] = v >> 24;

buf[1] = v >> 16;

@@ -4919,6 +4938,9 @@ set_h8300h (unsigned long machine)


if (machine == bfd_mach_h8300h || machine == bfd_mach_h8300hn || h8300smode)

h8300hmode = 1;

+

+ if(machine == bfd_mach_h8300hn || machine == bfd_mach_h8300sn || machine
== bfd_mach_h8300sxn)

+ h8300_normal_mode = 1;

}


/* Cover function of sim_state_free to free the cpu buffers as well. */

@@ -5054,9 +5076,9 @@ sim_load (SIM_DESC sd, char *prog, bfd *

switching between H8/300 and H8/300H programs without exiting

gdb. */


- if (h8300smode)

+ if (h8300smode && 0 == h8300_normal_mode)

memory_size = H8300S_MSIZE;

- else if (h8300hmode)

+ else if (h8300hmode && 0 == h8300_normal_mode)

memory_size = H8300H_MSIZE;

else

memory_size = H8300_MSIZE;

--------------------------------------------------------------------------

Attachment: tm-h8300.diff
Description: Binary data

Attachment: compile.diff
Description: Binary data

Attachment: h8300-tdep.diff
Description: Binary data

Attachment: coff-h8300.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]