This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [PATCH] Fix some error added with HEX2BIN
- To: "John S. Kallal" <kallal at CyberMax dot local>
- Subject: Re: [PATCH] Fix some error added with HEX2BIN
- From: Michael Snyder <msnyder at cygnus dot com>
- Date: Tue, 15 May 2001 19:05:41 -0700
- CC: gdb-patches at sources dot redhat dot com
- Organization: Red Hat
- References: <Pine.LNX.4.21.0105152108170.729-100000@CyberMax.local>
John,
Could you submit these changes separately, please?
We like to review changes that affect the behavior
separately from changes that are in the nature of clean-ups.
I think your bug-fix is correct, but it would be awkward to
approve that part and not the clean-up parts.
Thanks,
Michael
"John S. Kallal" wrote:
>
> The following patch corrects some errors that I think
> where added by the followin patch:
>
> http://sources.redhat.com/ml/gdb-patches/2001-05/msg00017.html.
>
> Without the patches, I was unable to work with the Linux
> version of GDBSERVER.
>
> 2001-05-15 John S Kallal <jskallal@home.com>
>
> * remote.c (remote_write_bytes) : Fixed string
> pointer & string end byte bug added when function
> of hex2bin added.
>
> * remote.c (remote_wait): Remove unused i variable.
> Merge variables p1 and p_temp into a single variable pt.
> Change long strings to use standard C string
> concatenation. Added new variable fieldsize to fix
> string pointer adjustment bug added when function call
> of hex2bin added.
>
> *** ../gdb+dejagnu-20010515-org/gdb/remote.c Tue May 15 10:26:57 2001
> --- gdb/remote.c Tue May 15 12:13:59 2001
> ***************
> *** 2825,2831 ****
> continue;
> case 'T': /* Status with PC, SP, FP, ... */
> {
> - int i;
> long regno;
> char* regs = (char*) alloca (MAX_REGISTER_RAW_SIZE);
>
> --- 2825,2830 ----
> ***************
> *** 2839,2882 ****
>
> while (*p)
> {
> ! unsigned char *p1;
> ! char *p_temp;
>
> /* Read the register number */
> ! regno = strtol ((const char *) p, &p_temp, 16);
> ! p1 = (unsigned char *) p_temp;
>
> ! if (p1 == p) /* No register number present here */
> {
> ! p1 = (unsigned char *) strchr ((const char *) p, ':');
> ! if (p1 == NULL)
> ! warning ("Malformed packet(a) (missing colon): %s\n\
> ! Packet: '%s'\n",
> ! p, buf);
> ! if (strncmp ((const char *) p, "thread", p1 - p) == 0)
> {
> ! p_temp = unpack_varlen_hex (++p1, &thread_num);
> record_currthread (thread_num);
> - p = (unsigned char *) p_temp;
> }
> }
> else
> {
> ! p = p1;
>
> if (*p++ != ':')
> ! warning ("Malformed packet(b) (missing colon): %s\n\
> ! Packet: '%s'\n",
> ! p, buf);
>
> if (regno >= NUM_REGS)
> ! warning ("Remote sent bad register number %ld: %s\n\
> ! Packet: '%s'\n",
> ! regno, p, buf);
>
> ! if (hex2bin (p, regs, REGISTER_RAW_SIZE (regno))
> ! < REGISTER_RAW_SIZE (regno))
> warning ("Remote reply is too short: %s", buf);
> supply_register (regno, regs);
> }
>
> --- 2838,2880 ----
>
> while (*p)
> {
> ! char *pt;
>
> /* Read the register number */
> ! regno = strtol ((const char *) p, &pt, 16);
>
> ! if (pt == (char *)p) /* No register number present here */
> {
> ! pt = strchr ((const char *) p, ':');
> ! if (pt == NULL)
> ! warning ("Malformed packet(a) (missing colon): %s\n"
> ! "Packet: '%s'\n", p, buf);
> !
> ! if (strncmp ((const char *) p, "thread", pt - (char *)p) == 0)
> {
> ! p = (unsigned char *)(unpack_varlen_hex (++pt, &thread_num) );
> record_currthread (thread_num);
> }
> }
> else
> {
> ! int fieldsize;
> !
> ! p = pt;
>
> if (*p++ != ':')
> ! warning ("Malformed packet(b) (missing colon): %s\n"
> ! "Packet: '%s'\n", p, buf);
>
> if (regno >= NUM_REGS)
> ! warning ("Remote sent bad register number %ld: %s\n"
> ! "Packet: '%s'\n", regno, p, buf);
>
> ! fieldsize = hex2bin (p, regs, REGISTER_RAW_SIZE (regno));
> ! p += 2*fieldsize;
> ! if ( fieldsize < REGISTER_RAW_SIZE (regno))
> warning ("Remote reply is too short: %s", buf);
> +
> supply_register (regno, regs);
> }
>
> ***************
> *** 2928,2935 ****
>
> if (symfile_objfile == NULL)
> {
> ! warning ("Relocation packet received with no symbol file. \
> ! Packet Dropped");
> goto got_status;
> }
>
> --- 2926,2933 ----
>
> if (symfile_objfile == NULL)
> {
> ! warning ("Relocation packet received with no symbol file. "
> ! "Packet Dropped");
> goto got_status;
> }
>
> ***************
> *** 3628,3633 ****
> --- 3626,3633 ----
> increasing byte addresses. Each byte is encoded as a two hex
> value. */
> nr_bytes = bin2hex (myaddr, p, todo);
> + p += 2*nr_bytes;
> + *p = '\0';
> break;
> case PACKET_SUPPORT_UNKNOWN:
> internal_error (__FILE__, __LINE__,