From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32004 invoked by alias); 26 Jul 2004 09:19:02 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 31991 invoked from network); 26 Jul 2004 09:18:59 -0000 Received: from unknown (HELO mail02.idc.renesas.com) (202.234.163.13) by sourceware.org with SMTP; 26 Jul 2004 09:18:59 -0000 Received: (from root@localhost) by guardian01.idc.renesas.com with id i6Q9IuqA007177; Mon, 26 Jul 2004 18:18:56 +0900 (JST) Received: from unknown [172.20.8.73] by guardian01.idc.renesas.com with SMTP id UAA07174 ; Mon, 26 Jul 2004 18:18:56 +0900 Received: from mrkaisv.hoku.renesas.com ([10.145.105.245]) by rnsmtp01.hoku_r.renesas.com (8.9.3/3.7W) with ESMTP id SAA09790; Mon, 26 Jul 2004 18:18:46 +0900 (JST) Received: from E5A02646 (unknown [10.145.105.81]) by mrkaisv.hoku.renesas.com (Postfix) with SMTP id 1D6F57980E2; Mon, 26 Jul 2004 18:18:46 +0900 (JST) Message-ID: <01a601c472f1$8da6f330$5169910a@E5A02646> From: "Kei Sakamoto" To: "Andrew Cagney" Cc: References: <020801c463e4$6c92a660$5169910a@E5A02646> <021701c463e4$ab8749c0$5169910a@E5A02646> <40F8493A.6050003@gnu.org> Subject: Re: [RFA/m32r] Fix breakpoint bug of m32rsdi protocol; remote-m32r-sdi.c re-indented. Date: Mon, 26 Jul 2004 09:19:00 -0000 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_01A3_01C4733C.FD7323F0" X-SW-Source: 2004-07/txt/msg00356.txt.bz2 This is a multi-part message in MIME format. ------=_NextPart_000_01A3_01C4733C.FD7323F0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Content-length: 812 Andrew, I revised my patch. > I've committed the attached which re-indents remote-m32r-sdi.c using > gdb/gdb_indent.sh. You'll want to merge in that change and strip out > any other stray mods. I've merged these changes. > can you add helper functions like: > send_l4_data (SDI_WRITE_MEMORY, 0xffff8200 + 4 * i, 4, 0xffffffff); > for each of these cases (and any others you feel useful). I added several helper functions. Some sequences still remain because they are unique. But most sequences are replaced with helper functions. OK to commit? === 2004-07-26 Kei Sakamoto * remote-m32r-sdi.c: Fix breakpoint bug. (send_cmd, send_one_arg_cmd, send_two_arg_cmd, send_three_arg_cmd, recv_char_data, recv_long_data): New functions to replace communication sequences. ------=_NextPart_000_01A3_01C4733C.FD7323F0 Content-Type: application/octet-stream; name="remote-m32r-sdi.c.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="remote-m32r-sdi.c.patch" Content-length: 27551 Index: remote-m32r-sdi.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /cvs/src/src/gdb/remote-m32r-sdi.c,v=0A= retrieving revision 1.6=0A= diff -u -r1.6 remote-m32r-sdi.c=0A= --- remote-m32r-sdi.c 22 Jul 2004 01:31:49 -0000 1.6=0A= +++ remote-m32r-sdi.c 26 Jul 2004 08:53:27 -0000=0A= @@ -63,12 +63,6 @@=0A= static int max_ib_breakpoints;=0A= static unsigned long bp_address[MAX_BREAKPOINTS];=0A= static unsigned char bp_data[MAX_BREAKPOINTS][4];=0A= -static const unsigned char ib_bp_entry_enable[] =3D {=0A= - 0x00, 0x00, 0x00, 0x06=0A= -};=0A= -static const unsigned char ib_bp_entry_disable[] =3D {=0A= - 0x00, 0x00, 0x00, 0x00=0A= -};=0A= =20=0A= /* dbt -> nop */=0A= static const unsigned char dbt_bp_entry[] =3D {=0A= @@ -224,20 +218,72 @@=0A= memcpy (buf, &val, 4);=0A= }=0A= =20=0A= +static int=0A= +send_cmd (unsigned char cmd)=0A= +{=0A= + unsigned char buf[1];=0A= + buf[0] =3D cmd;=0A= + return send_data (buf, 1);=0A= +}=0A= +=0A= +static int=0A= +send_one_arg_cmd (unsigned char cmd, unsigned char arg1)=0A= +{=0A= + unsigned char buf[2];=0A= + buf[0] =3D cmd;=0A= + buf[1] =3D arg1;=0A= + return send_data (buf, 2);=0A= +}=0A= +=0A= +static int=0A= +send_two_arg_cmd (unsigned char cmd, unsigned char arg1, unsigned long arg= 2)=0A= +{=0A= + unsigned char buf[6];=0A= + buf[0] =3D cmd;=0A= + buf[1] =3D arg1;=0A= + store_long_parameter (buf + 2, arg2);=0A= + return send_data (buf, 6);=0A= +}=0A= +=0A= +static int=0A= +send_three_arg_cmd (unsigned char cmd, unsigned long arg1, unsigned long a= rg2,=0A= + unsigned long arg3)=0A= +{=0A= + unsigned char buf[13];=0A= + buf[0] =3D cmd;=0A= + store_long_parameter (buf + 1, arg1);=0A= + store_long_parameter (buf + 5, arg2);=0A= + store_long_parameter (buf + 9, arg3);=0A= + return send_data (buf, 13);=0A= +}=0A= +=0A= +static unsigned char=0A= +recv_char_data (void)=0A= +{=0A= + unsigned char val;=0A= + recv_data (&val, 1);=0A= + return val;=0A= +}=0A= +=0A= +static unsigned long=0A= +recv_long_data (void)=0A= +{=0A= + unsigned long val;=0A= + recv_data (&val, 4);=0A= + return ntohl (val);=0A= +}=0A= +=0A= +=0A= /* Check if MMU is on */=0A= static void=0A= check_mmu_status (void)=0A= {=0A= unsigned long val;=0A= - unsigned char buf[2];=0A= =20=0A= /* Read PC address */=0A= - buf[0] =3D SDI_READ_CPU_REG;=0A= - buf[1] =3D SDI_REG_BPC;=0A= - if (send_data (buf, 2) =3D=3D -1)=0A= + if (send_one_arg_cmd (SDI_READ_CPU_REG, SDI_REG_BPC) =3D=3D -1)=0A= return;=0A= - recv_data (&val, 4);=0A= - val =3D ntohl (val);=0A= + val =3D recv_long_data ();=0A= if ((val & 0xc0000000) =3D=3D 0x80000000)=0A= {=0A= mmu_on =3D 1;=0A= @@ -245,12 +291,9 @@=0A= }=0A= =20=0A= /* Read EVB address */=0A= - buf[0] =3D SDI_READ_CPU_REG;=0A= - buf[1] =3D SDI_REG_EVB;=0A= - if (send_data (buf, 2) =3D=3D -1)=0A= + if (send_one_arg_cmd (SDI_READ_CPU_REG, SDI_REG_EVB) =3D=3D -1)=0A= return;=0A= - recv_data (&val, 4);=0A= - val =3D ntohl (val);=0A= + val =3D recv_long_data ();=0A= if ((val & 0xc0000000) =3D=3D 0x80000000)=0A= {=0A= mmu_on =3D 1;=0A= @@ -308,7 +351,6 @@=0A= struct sockaddr_in server_addr;=0A= char *port_str, hostname[256];=0A= int port;=0A= - unsigned char buf[2];=0A= int i, n;=0A= int yes =3D 1;=0A= =20=0A= @@ -337,16 +379,12 @@=0A= if (get_ack () =3D=3D -1)=0A= error ("Cannot connect to SDI target\n");=0A= =20=0A= - buf[0] =3D SDI_OPEN;=0A= - if (send_data (buf, 1) =3D=3D -1)=0A= + if (send_cmd (SDI_OPEN) =3D=3D -1)=0A= error ("Cannot connect to SDI target\n");=0A= =20=0A= /* Get maximum number of ib breakpoints */=0A= - buf[0] =3D SDI_GET_ATTR;=0A= - buf[1] =3D SDI_ATTR_BRK;=0A= - send_data (buf, 2);=0A= - recv_data (buf, 1);=0A= - max_ib_breakpoints =3D buf[0];=0A= + send_one_arg_cmd (SDI_GET_ATTR, SDI_ATTR_BRK);=0A= + max_ib_breakpoints =3D recv_char_data ();=0A= if (remote_debug)=0A= printf_filtered ("Max IB Breakpoints =3D %d\n", max_ib_breakpoints);= =0A= =20=0A= @@ -355,11 +393,8 @@=0A= bp_address[i] =3D 0xffffffff;=0A= =20=0A= /* Get maximum number of access breaks. */=0A= - buf[0] =3D SDI_GET_ATTR;=0A= - buf[1] =3D SDI_ATTR_ABRK;=0A= - send_data (buf, 2);=0A= - recv_data (buf, 1);=0A= - max_access_breaks =3D buf[0];=0A= + send_one_arg_cmd (SDI_GET_ATTR, SDI_ATTR_ABRK);=0A= + max_access_breaks =3D recv_char_data ();=0A= if (remote_debug)=0A= printf_filtered ("Max Access Breaks =3D %d\n", max_access_breaks);=0A= =20=0A= @@ -370,9 +405,7 @@=0A= check_mmu_status ();=0A= =20=0A= /* Get the name of chip on target board. */=0A= - buf[0] =3D SDI_GET_ATTR;=0A= - buf[1] =3D SDI_ATTR_NAME;=0A= - send_data (buf, 2);=0A= + send_one_arg_cmd (SDI_GET_ATTR, SDI_ATTR_NAME);=0A= recv_data (chip_name, 64);=0A= =20=0A= if (from_tty)=0A= @@ -385,15 +418,12 @@=0A= static void=0A= m32r_close (int quitting)=0A= {=0A= - unsigned char buf[1];=0A= -=0A= if (remote_debug)=0A= fprintf_unfiltered (gdb_stdlog, "m32r_close(%d)\n", quitting);=0A= =20=0A= if (sdi_desc)=0A= {=0A= - buf[0] =3D SDI_CLOSE;=0A= - send_data (buf, 1);=0A= + send_cmd (SDI_CLOSE);=0A= serial_close (sdi_desc);=0A= sdi_desc =3D NULL;=0A= }=0A= @@ -408,6 +438,7 @@=0A= m32r_resume (ptid_t ptid, int step, enum target_signal sig)=0A= {=0A= unsigned long pc_addr, bp_addr, ab_addr;=0A= + int ib_breakpoints;=0A= unsigned char buf[13];=0A= int i;=0A= =20=0A= @@ -451,206 +482,181 @@=0A= }=0A= =20=0A= /* Set PC. */=0A= - buf[0] =3D SDI_WRITE_CPU_REG;=0A= - buf[1] =3D SDI_REG_BPC;=0A= - store_long_parameter (buf + 2, pc_addr);=0A= - send_data (buf, 6);=0A= + send_two_arg_cmd (SDI_WRITE_CPU_REG, SDI_REG_BPC, pc_addr);=0A= =20=0A= /* step mode. */=0A= step_mode =3D step;=0A= if (step)=0A= {=0A= /* Set PBP. */=0A= - buf[0] =3D SDI_WRITE_CPU_REG;=0A= - buf[1] =3D SDI_REG_PBP;=0A= - store_long_parameter (buf + 2, pc_addr | 1);=0A= - send_data (buf, 6);=0A= + send_two_arg_cmd (SDI_WRITE_CPU_REG, SDI_REG_PBP, pc_addr | 1);=0A= }=0A= else=0A= {=0A= - int ib_breakpoints;=0A= + /* Unset PBP. */=0A= + send_two_arg_cmd (SDI_WRITE_CPU_REG, SDI_REG_PBP, 0x00000000);=0A= + }=0A= +=0A= + if (use_ib_breakpoints)=0A= + ib_breakpoints =3D max_ib_breakpoints;=0A= + else=0A= + ib_breakpoints =3D 0;=0A= +=0A= + /* Set ib breakpoints. */=0A= + for (i =3D 0; i < ib_breakpoints; i++)=0A= + {=0A= + bp_addr =3D bp_address[i];=0A= =20=0A= - if (use_ib_breakpoints)=0A= - ib_breakpoints =3D max_ib_breakpoints;=0A= + if (bp_addr =3D=3D 0xffffffff)=0A= + continue;=0A= +=0A= + /* Set PBP. */=0A= + if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8000 + 4 * i, 4,=0A= + 0x00000006);=0A= else=0A= - ib_breakpoints =3D 0;=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8000 + 4 * i, 4,=0A= + 0x06000000);=0A= +=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8080 + 4 * i, 4, bp_addr= );=0A= + }=0A= +=0A= + /* Set dbt breakpoints. */=0A= + for (i =3D ib_breakpoints; i < MAX_BREAKPOINTS; i++)=0A= + {=0A= + bp_addr =3D bp_address[i];=0A= +=0A= + if (bp_addr =3D=3D 0xffffffff)=0A= + continue;=0A= +=0A= + if (!mmu_on)=0A= + bp_addr &=3D 0x7fffffff;=0A= =20=0A= - /* Set ib breakpoints. */=0A= - for (i =3D 0; i < ib_breakpoints; i++)=0A= + /* Write DBT instruction. */=0A= + buf[0] =3D SDI_WRITE_MEMORY;=0A= + store_long_parameter (buf + 1, bp_addr);=0A= + store_long_parameter (buf + 5, 4);=0A= + if ((bp_addr & 2) =3D=3D 0 && bp_addr !=3D (pc_addr & 0xfffffffc))= =0A= {=0A= - bp_addr =3D bp_address[i];=0A= - if (bp_addr !=3D 0xffffffff && bp_addr !=3D pc_addr)=0A= + if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= {=0A= - /* Set PBP. */=0A= - buf[0] =3D SDI_WRITE_MEMORY;=0A= - store_long_parameter (buf + 1, 0xffff8000 + 4 * i);=0A= - store_long_parameter (buf + 5, 4);=0A= - if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= - {=0A= - buf[9] =3D ib_bp_entry_enable[0];=0A= - buf[10] =3D ib_bp_entry_enable[1];=0A= - buf[11] =3D ib_bp_entry_enable[2];=0A= - buf[12] =3D ib_bp_entry_enable[3];=0A= - }=0A= - else=0A= - {=0A= - buf[9] =3D ib_bp_entry_enable[3];=0A= - buf[10] =3D ib_bp_entry_enable[2];=0A= - buf[11] =3D ib_bp_entry_enable[1];=0A= - buf[12] =3D ib_bp_entry_enable[0];=0A= - }=0A= - send_data (buf, 13);=0A= -=0A= - buf[0] =3D SDI_WRITE_MEMORY;=0A= - store_long_parameter (buf + 1, 0xffff8080 + 4 * i);=0A= - store_long_parameter (buf + 5, 4);=0A= - store_unsigned_integer (buf + 9, 4, bp_addr);=0A= - send_data (buf, 13);=0A= + buf[9] =3D dbt_bp_entry[0];=0A= + buf[10] =3D dbt_bp_entry[1];=0A= + buf[11] =3D dbt_bp_entry[2];=0A= + buf[12] =3D dbt_bp_entry[3];=0A= + }=0A= + else=0A= + {=0A= + buf[9] =3D dbt_bp_entry[3];=0A= + buf[10] =3D dbt_bp_entry[2];=0A= + buf[11] =3D dbt_bp_entry[1];=0A= + buf[12] =3D dbt_bp_entry[0];=0A= }=0A= }=0A= -=0A= - /* Set dbt breakpoints. */=0A= - for (i =3D ib_breakpoints; i < MAX_BREAKPOINTS; i++)=0A= + else=0A= {=0A= - bp_addr =3D bp_address[i];=0A= - if (bp_addr !=3D 0xffffffff && bp_addr !=3D pc_addr)=0A= + if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= {=0A= - if (!mmu_on)=0A= - bp_addr &=3D 0x7fffffff;=0A= -=0A= - /* Write DBT instruction. */=0A= - buf[0] =3D SDI_WRITE_MEMORY;=0A= - if ((bp_addr & 2) =3D=3D 0 && bp_addr !=3D (pc_addr & 0xfffffffc))= =0A= + if ((bp_addr & 2) =3D=3D 0)=0A= {=0A= - store_long_parameter (buf + 1, bp_addr);=0A= - store_long_parameter (buf + 5, 4);=0A= - if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= - {=0A= - buf[9] =3D dbt_bp_entry[0];=0A= - buf[10] =3D dbt_bp_entry[1];=0A= - buf[11] =3D dbt_bp_entry[2];=0A= - buf[12] =3D dbt_bp_entry[3];=0A= - }=0A= - else=0A= - {=0A= - buf[9] =3D dbt_bp_entry[3];=0A= - buf[10] =3D dbt_bp_entry[2];=0A= - buf[11] =3D dbt_bp_entry[1];=0A= - buf[12] =3D dbt_bp_entry[0];=0A= - }=0A= - send_data (buf, 13);=0A= + buf[9] =3D dbt_bp_entry[0];=0A= + buf[10] =3D dbt_bp_entry[1];=0A= + buf[11] =3D bp_data[i][2] & 0x7f;=0A= + buf[12] =3D bp_data[i][3];=0A= }=0A= else=0A= {=0A= - if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= - store_long_parameter (buf + 1, bp_addr);=0A= - else if ((bp_addr & 2) =3D=3D 0)=0A= - store_long_parameter (buf + 1, bp_addr + 2);=0A= - else=0A= - store_long_parameter (buf + 1, bp_addr - 2);=0A= - store_long_parameter (buf + 5, 2);=0A= - if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= - {=0A= - buf[9] =3D dbt_bp_entry[0];=0A= - buf[10] =3D dbt_bp_entry[1];=0A= - }=0A= - else=0A= - {=0A= - buf[9] =3D dbt_bp_entry[1];=0A= - buf[10] =3D dbt_bp_entry[0];=0A= - }=0A= - send_data (buf, 11);=0A= + buf[9] =3D bp_data[i][0];=0A= + buf[10] =3D bp_data[i][1];=0A= + buf[11] =3D dbt_bp_entry[0];=0A= + buf[12] =3D dbt_bp_entry[1];=0A= }=0A= }=0A= - }=0A= -=0A= - /* Set access breaks. */=0A= - for (i =3D 0; i < max_access_breaks; i++)=0A= - {=0A= - ab_addr =3D ab_address[i];=0A= - if (ab_addr !=3D 0x00000000)=0A= + else=0A= {=0A= - /* DBC register */=0A= - buf[0] =3D SDI_WRITE_MEMORY;=0A= - store_long_parameter (buf + 1, 0xffff8100 + 4 * i);=0A= - store_long_parameter (buf + 5, 4);=0A= - if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= + if ((bp_addr & 2) =3D=3D 0)=0A= {=0A= - buf[9] =3D 0x00;=0A= - buf[10] =3D 0x00;=0A= - buf[11] =3D 0x00;=0A= - switch (ab_type[i])=0A= - {=0A= - case 0: /* write watch */=0A= - buf[12] =3D 0x86;=0A= - break;=0A= - case 1: /* read watch */=0A= - buf[12] =3D 0x46;=0A= - break;=0A= - case 2: /* access watch */=0A= - buf[12] =3D 0x06;=0A= - break;=0A= - }=0A= + buf[9] =3D bp_data[i][0];=0A= + buf[10] =3D bp_data[i][1] & 0x7f;=0A= + buf[11] =3D dbt_bp_entry[1];=0A= + buf[12] =3D dbt_bp_entry[0];=0A= }=0A= else=0A= {=0A= - switch (ab_type[i])=0A= - {=0A= - case 0: /* write watch */=0A= - buf[9] =3D 0x86;=0A= - break;=0A= - case 1: /* read watch */=0A= - buf[9] =3D 0x46;=0A= - break;=0A= - case 2: /* access watch */=0A= - buf[9] =3D 0x06;=0A= - break;=0A= - }=0A= - buf[10] =3D 0x00;=0A= - buf[11] =3D 0x00;=0A= - buf[12] =3D 0x00;=0A= + buf[9] =3D dbt_bp_entry[1];=0A= + buf[10] =3D dbt_bp_entry[0];=0A= + buf[11] =3D bp_data[i][2];=0A= + buf[12] =3D bp_data[i][3];=0A= }=0A= - send_data (buf, 13);=0A= -=0A= - /* DBAH register */=0A= - buf[0] =3D SDI_WRITE_MEMORY;=0A= - store_long_parameter (buf + 1, 0xffff8180 + 4 * i);=0A= - store_long_parameter (buf + 5, 4);=0A= - store_unsigned_integer (buf + 9, 4, ab_addr);=0A= - send_data (buf, 13);=0A= + }=0A= + }=0A= + send_data (buf, 13);=0A= + }=0A= =20=0A= - /* DBAL register */=0A= - buf[0] =3D SDI_WRITE_MEMORY;=0A= - store_long_parameter (buf + 1, 0xffff8200 + 4 * i);=0A= - store_long_parameter (buf + 5, 4);=0A= - store_long_parameter (buf + 9, 0xffffffff);=0A= - send_data (buf, 13);=0A= + /* Set access breaks. */=0A= + for (i =3D 0; i < max_access_breaks; i++)=0A= + {=0A= + ab_addr =3D ab_address[i];=0A= =20=0A= - /* DBD register */=0A= - buf[0] =3D SDI_WRITE_MEMORY;=0A= - store_long_parameter (buf + 1, 0xffff8280 + 4 * i);=0A= - store_long_parameter (buf + 5, 4);=0A= - store_long_parameter (buf + 9, 0x00000000);=0A= - send_data (buf, 13);=0A= + if (ab_addr =3D=3D 0x00000000)=0A= + continue;=0A= =20=0A= - /* DBDM register */=0A= - buf[0] =3D SDI_WRITE_MEMORY;=0A= - store_long_parameter (buf + 1, 0xffff8300 + 4 * i);=0A= - store_long_parameter (buf + 5, 4);=0A= - store_long_parameter (buf + 9, 0x00000000);=0A= - send_data (buf, 13);=0A= + /* DBC register */=0A= + if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= + {=0A= + switch (ab_type[i])=0A= + {=0A= + case 0: /* write watch */=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8100 + 4 * i, 4,=0A= + 0x00000086);=0A= + break;=0A= + case 1: /* read watch */=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8100 + 4 * i, 4,=0A= + 0x00000046);=0A= + break;=0A= + case 2: /* access watch */=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8100 + 4 * i, 4,=0A= + 0x00000006);=0A= + break;=0A= + }=0A= + }=0A= + else=0A= + {=0A= + switch (ab_type[i])=0A= + {=0A= + case 0: /* write watch */=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8100 + 4 * i, 4,=0A= + 0x86000000);=0A= + break;=0A= + case 1: /* read watch */=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8100 + 4 * i, 4,=0A= + 0x46000000);=0A= + break;=0A= + case 2: /* access watch */=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8100 + 4 * i, 4,=0A= + 0x06000000);=0A= + break;=0A= }=0A= }=0A= =20=0A= - /* Unset PBP. */=0A= - buf[0] =3D SDI_WRITE_CPU_REG;=0A= - buf[1] =3D SDI_REG_PBP;=0A= - store_long_parameter (buf + 2, 0x00000000);=0A= - send_data (buf, 6);=0A= + /* DBAH register */=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8180 + 4 * i, 4, ab_addr= );=0A= +=0A= + /* DBAL register */=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8200 + 4 * i, 4,=0A= + 0xffffffff);=0A= +=0A= + /* DBD register */=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8280 + 4 * i, 4,=0A= + 0x00000000);=0A= +=0A= + /* DBDM register */=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8300 + 4 * i, 4,=0A= + 0x00000000);=0A= }=0A= =20=0A= - buf[0] =3D SDI_EXEC_CPU;=0A= - send_data (buf, 1);=0A= + /* Resume program. */=0A= + send_cmd (SDI_EXEC_CPU);=0A= =20=0A= /* Without this, some commands which require an active target (such as k= ill)=0A= won't work. This variable serves (at least) double duty as both the = pid=0A= @@ -679,6 +685,7 @@=0A= {=0A= static RETSIGTYPE (*prev_sigint) ();=0A= unsigned long bp_addr, pc_addr;=0A= + int ib_breakpoints;=0A= long i;=0A= unsigned char buf[13];=0A= unsigned long val;=0A= @@ -746,130 +753,106 @@=0A= last_pc_addr =3D 0xffffffff;=0A= }=0A= =20=0A= - /* Breakpoints are inserted only for "next" command */=0A= - if (!step_mode)=0A= - {=0A= - int ib_breakpoints;=0A= -=0A= - if (use_ib_breakpoints)=0A= - ib_breakpoints =3D max_ib_breakpoints;=0A= - else=0A= - ib_breakpoints =3D 0;=0A= + if (use_ib_breakpoints)=0A= + ib_breakpoints =3D max_ib_breakpoints;=0A= + else=0A= + ib_breakpoints =3D 0;=0A= =20=0A= - /* Set back pc by 2 if m32r is stopped with dbt. */=0A= - buf[0] =3D SDI_READ_CPU_REG;=0A= - buf[1] =3D SDI_REG_BPC;=0A= - send_data (buf, 2);=0A= - recv_data (&val, 4);=0A= - pc_addr =3D ntohl (val) - 2;=0A= - for (i =3D ib_breakpoints; i < MAX_BREAKPOINTS; i++)=0A= - {=0A= - if (pc_addr =3D=3D bp_address[i])=0A= + /* Set back pc by 2 if m32r is stopped with dbt. */=0A= + last_pc_addr =3D 0xffffffff;=0A= + send_one_arg_cmd (SDI_READ_CPU_REG, SDI_REG_BPC);=0A= + pc_addr =3D recv_long_data () - 2;=0A= + for (i =3D ib_breakpoints; i < MAX_BREAKPOINTS; i++)=0A= + {=0A= + if (pc_addr =3D=3D bp_address[i])=0A= + {=0A= + send_two_arg_cmd (SDI_WRITE_CPU_REG, SDI_REG_BPC, pc_addr);=0A= +=0A= + /* If there is a parallel instruction with +2 offset at pc=0A= + address, we have to take care of it later. */=0A= + if ((pc_addr & 0x2) !=3D 0)=0A= {=0A= - buf[0] =3D SDI_WRITE_CPU_REG;=0A= - buf[1] =3D SDI_REG_BPC;=0A= - store_long_parameter (buf + 2, pc_addr);=0A= - send_data (buf, 6);=0A= -=0A= - /* If there is a parallel instruction with +2 offset at pc=0A= - address, we have to take care of it later. */=0A= - if ((pc_addr & 0x2) !=3D 0)=0A= + if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= {=0A= - if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= + if ((bp_data[i][2] & 0x80) !=3D 0)=0A= {=0A= - if ((bp_data[i][2] & 0x80) !=3D 0)=0A= - {=0A= - last_pc_addr =3D pc_addr;=0A= - last_pc_addr_data[0] =3D bp_data[i][2];=0A= - last_pc_addr_data[1] =3D bp_data[i][3];=0A= - }=0A= + last_pc_addr =3D pc_addr;=0A= + last_pc_addr_data[0] =3D bp_data[i][2];=0A= + last_pc_addr_data[1] =3D bp_data[i][3];=0A= }=0A= - else=0A= + }=0A= + else=0A= + {=0A= + if ((bp_data[i][1] & 0x80) !=3D 0)=0A= {=0A= - if ((bp_data[i][1] & 0x80) !=3D 0)=0A= - {=0A= - last_pc_addr =3D pc_addr;=0A= - last_pc_addr_data[0] =3D bp_data[i][1];=0A= - last_pc_addr_data[1] =3D bp_data[i][0];=0A= - }=0A= + last_pc_addr =3D pc_addr;=0A= + last_pc_addr_data[0] =3D bp_data[i][1];=0A= + last_pc_addr_data[1] =3D bp_data[i][0];=0A= }=0A= }=0A= - break;=0A= }=0A= + break;=0A= }=0A= + }=0A= =20=0A= - /* Remove ib breakpoints. */=0A= - for (i =3D 0; i < ib_breakpoints; i++)=0A= - {=0A= - if (bp_address[i] !=3D 0xffffffff)=0A= - {=0A= - buf[0] =3D SDI_WRITE_MEMORY;=0A= - store_long_parameter (buf + 1, 0xffff8000 + 4 * i);=0A= - store_long_parameter (buf + 5, 4);=0A= - buf[9] =3D ib_bp_entry_disable[0];=0A= - buf[10] =3D ib_bp_entry_disable[1];=0A= - buf[11] =3D ib_bp_entry_disable[2];=0A= - buf[12] =3D ib_bp_entry_disable[3];=0A= - send_data (buf, 13);=0A= - }=0A= - }=0A= - /* Remove dbt breakpoints. */=0A= - for (i =3D ib_breakpoints; i < MAX_BREAKPOINTS; i++)=0A= + /* Remove ib breakpoints. */=0A= + for (i =3D 0; i < ib_breakpoints; i++)=0A= + {=0A= + if (bp_address[i] !=3D 0xffffffff)=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8000 + 4 * i, 4,=0A= + 0x00000000);=0A= + }=0A= + /* Remove dbt breakpoints. */=0A= + for (i =3D ib_breakpoints; i < MAX_BREAKPOINTS; i++)=0A= + {=0A= + bp_addr =3D bp_address[i];=0A= + if (bp_addr !=3D 0xffffffff)=0A= {=0A= - bp_addr =3D bp_address[i];=0A= - if (bp_addr !=3D 0xffffffff)=0A= - {=0A= - if (!mmu_on)=0A= - bp_addr &=3D 0x7fffffff;=0A= - buf[0] =3D SDI_WRITE_MEMORY;=0A= - store_long_parameter (buf + 1, bp_addr & 0xfffffffc);=0A= - store_long_parameter (buf + 5, 4);=0A= - buf[9] =3D bp_data[i][0];=0A= - buf[10] =3D bp_data[i][1];=0A= - buf[11] =3D bp_data[i][2];=0A= - buf[12] =3D bp_data[i][3];=0A= - send_data (buf, 13);=0A= - }=0A= + if (!mmu_on)=0A= + bp_addr &=3D 0x7fffffff;=0A= + buf[0] =3D SDI_READ_MEMORY;=0A= + store_long_parameter (buf + 1, bp_addr & 0xfffffffc);=0A= + store_long_parameter (buf + 5, 4);=0A= + buf[9] =3D bp_data[i][0];=0A= + buf[10] =3D bp_data[i][1];=0A= + buf[11] =3D bp_data[i][2];=0A= + buf[12] =3D bp_data[i][3];=0A= + send_data (buf, 13);=0A= }=0A= + }=0A= =20=0A= - /* Remove access breaks. */=0A= - hit_watchpoint_addr =3D 0;=0A= - for (i =3D 0; i < max_access_breaks; i++)=0A= - {=0A= - if (ab_address[i] !=3D 0x00000000)=0A= + /* Remove access breaks. */=0A= + hit_watchpoint_addr =3D 0;=0A= + for (i =3D 0; i < max_access_breaks; i++)=0A= + {=0A= + if (ab_address[i] !=3D 0x00000000)=0A= + {=0A= + buf[0] =3D SDI_READ_MEMORY;=0A= + store_long_parameter (buf + 1, 0xffff8100 + 4 * i);=0A= + store_long_parameter (buf + 5, 4);=0A= + serial_write (sdi_desc, buf, 9);=0A= + c =3D serial_readchar (sdi_desc, SDI_TIMEOUT);=0A= + if (c !=3D '-' && recv_data (buf, 4) !=3D -1)=0A= {=0A= - buf[0] =3D SDI_READ_MEMORY;=0A= - store_long_parameter (buf + 1, 0xffff8100 + 4 * i);=0A= - store_long_parameter (buf + 5, 4);=0A= - serial_write (sdi_desc, buf, 9);=0A= - c =3D serial_readchar (sdi_desc, SDI_TIMEOUT);=0A= - if (c !=3D '-' && recv_data (buf, 4) !=3D -1)=0A= + if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= {=0A= - if (TARGET_BYTE_ORDER =3D=3D BFD_ENDIAN_BIG)=0A= - {=0A= - if ((buf[3] & 0x1) =3D=3D 0x1)=0A= - hit_watchpoint_addr =3D ab_address[i];=0A= - }=0A= - else=0A= - {=0A= - if ((buf[0] & 0x1) =3D=3D 0x1)=0A= - hit_watchpoint_addr =3D ab_address[i];=0A= - }=0A= + if ((buf[3] & 0x1) =3D=3D 0x1)=0A= + hit_watchpoint_addr =3D ab_address[i];=0A= + }=0A= + else=0A= + {=0A= + if ((buf[0] & 0x1) =3D=3D 0x1)=0A= + hit_watchpoint_addr =3D ab_address[i];=0A= }=0A= -=0A= - buf[0] =3D SDI_WRITE_MEMORY;=0A= - store_long_parameter (buf + 1, 0xffff8100 + 4 * i);=0A= - store_long_parameter (buf + 5, 4);=0A= - store_long_parameter (buf + 9, 0x00000000);=0A= - send_data (buf, 13);=0A= }=0A= - }=0A= =20=0A= - if (remote_debug)=0A= - fprintf_unfiltered (gdb_stdlog, "pc =3D> 0x%lx\n", pc_addr);=0A= + send_three_arg_cmd (SDI_WRITE_MEMORY, 0xffff8100 + 4 * i, 4,=0A= + 0x00000000);=0A= + }=0A= }=0A= - else=0A= - last_pc_addr =3D 0xffffffff;=0A= +=0A= + if (remote_debug)=0A= + fprintf_unfiltered (gdb_stdlog, "pc =3D> 0x%lx\n", pc_addr);=0A= =20=0A= return inferior_ptid;=0A= }=0A= @@ -933,7 +916,6 @@=0A= m32r_fetch_register (int regno)=0A= {=0A= unsigned long val, val2, regid;=0A= - unsigned char buf[2];=0A= =20=0A= if (regno =3D=3D -1)=0A= m32r_fetch_registers ();=0A= @@ -942,19 +924,13 @@=0A= char buffer[MAX_REGISTER_SIZE];=0A= =20=0A= regid =3D get_reg_id (regno);=0A= - buf[0] =3D SDI_READ_CPU_REG;=0A= - buf[1] =3D regid;=0A= - send_data (buf, 2);=0A= - recv_data (&val, 4);=0A= - val =3D ntohl (val);=0A= + send_one_arg_cmd (SDI_READ_CPU_REG, regid);=0A= + val =3D recv_long_data ();=0A= =20=0A= if (regid =3D=3D SDI_REG_PSW)=0A= {=0A= - buf[0] =3D SDI_READ_CPU_REG;=0A= - buf[1] =3D SDI_REG_BBPSW;=0A= - send_data (buf, 2);=0A= - recv_data (&val2, 4);=0A= - val2 =3D ntohl (val2);=0A= + send_one_arg_cmd (SDI_READ_CPU_REG, SDI_REG_BBPSW);=0A= + val2 =3D recv_long_data ();=0A= val =3D ((0x00c1 & val2) << 8) | ((0xc100 & val) >> 8);=0A= }=0A= =20=0A= @@ -992,7 +968,6 @@=0A= {=0A= int regid;=0A= ULONGEST regval, tmp;=0A= - unsigned char buf[6];=0A= =20=0A= if (regno =3D=3D -1)=0A= m32r_store_registers ();=0A= @@ -1005,36 +980,21 @@=0A= {=0A= unsigned long psw, bbpsw;=0A= =20=0A= - buf[0] =3D SDI_READ_CPU_REG;=0A= - buf[1] =3D SDI_REG_PSW;=0A= - send_data (buf, 2);=0A= - recv_data (&psw, 4);=0A= - psw =3D ntohl (psw);=0A= -=0A= - buf[0] =3D SDI_READ_CPU_REG;=0A= - buf[1] =3D SDI_REG_BBPSW;=0A= - send_data (buf, 2);=0A= - recv_data (&bbpsw, 4);=0A= - bbpsw =3D ntohl (bbpsw);=0A= + send_one_arg_cmd (SDI_READ_CPU_REG, SDI_REG_PSW);=0A= + psw =3D recv_long_data ();=0A= +=0A= + send_one_arg_cmd (SDI_READ_CPU_REG, SDI_REG_BBPSW);=0A= + bbpsw =3D recv_long_data ();=0A= =20=0A= tmp =3D (0x00c1 & psw) | ((0x00c1 & regval) << 8);=0A= - buf[0] =3D SDI_WRITE_CPU_REG;=0A= - buf[1] =3D SDI_REG_PSW;=0A= - store_long_parameter (buf + 2, tmp);=0A= - send_data (buf, 6);=0A= + send_two_arg_cmd (SDI_WRITE_CPU_REG, SDI_REG_PSW, tmp);=0A= =20=0A= tmp =3D (0x0030 & bbpsw) | ((0xc100 & regval) >> 8);=0A= - buf[0] =3D SDI_WRITE_CPU_REG;=0A= - buf[1] =3D SDI_REG_BBPSW;=0A= - store_long_parameter (buf + 2, tmp);=0A= - send_data (buf, 6);=0A= + send_two_arg_cmd (SDI_WRITE_CPU_REG, SDI_REG_BBPSW, tmp);=0A= }=0A= else=0A= {=0A= - buf[0] =3D SDI_WRITE_CPU_REG;=0A= - buf[1] =3D regid;=0A= - store_long_parameter (buf + 2, regval);=0A= - send_data (buf, 6);=0A= + send_two_arg_cmd (SDI_WRITE_CPU_REG, regid, regval);=0A= }=0A= =20=0A= if (remote_debug)=0A= @@ -1422,13 +1382,10 @@=0A= static void=0A= m32r_stop (void)=0A= {=0A= - unsigned char buf[1];=0A= -=0A= if (remote_debug)=0A= fprintf_unfiltered (gdb_stdlog, "m32r_stop()\n");=0A= =20=0A= - buf[0] =3D SDI_STOP_CPU;=0A= - send_data (buf, 1);=0A= + send_cmd (SDI_STOP_CPU);=0A= =20=0A= return;=0A= }=0A= @@ -1509,13 +1466,10 @@=0A= static void=0A= sdireset_command (char *args, int from_tty)=0A= {=0A= - unsigned char buf[1];=0A= -=0A= if (remote_debug)=0A= fprintf_unfiltered (gdb_stdlog, "m32r_sdireset()\n");=0A= =20=0A= - buf[0] =3D SDI_OPEN;=0A= - send_data (buf, 1);=0A= + send_cmd (SDI_OPEN);=0A= =20=0A= inferior_ptid =3D null_ptid;=0A= }=0A= @@ -1533,8 +1487,7 @@=0A= if (!sdi_desc)=0A= return;=0A= =20=0A= - buf[0] =3D SDI_STATUS;=0A= - send_data (buf, 1);=0A= + send_cmd (SDI_STATUS);=0A= for (i =3D 0; i < 4096; i++)=0A= {=0A= c =3D serial_readchar (sdi_desc, SDI_TIMEOUT);=0A= ------=_NextPart_000_01A3_01C4733C.FD7323F0--