[Openocd-development] fix ancient bug SEGFAULT in irscan

2009-05-12 Thread Øyvind Harboe
I couldn't believe my eyes when I saw what the bug was. irscan
has *always* been broken. I checked as far back as svn 345.

A couple of possible explanations:

- irscan has never really been used
- events have somehow conspired to hide the bugs
- I'm missing something

Known problems in irscan:

- does not support 32 bit fields(?). This maybe a problem for
omap devices(?)
- why not reuse the new drscan code?


-- 
Øyvind Harboe
Embedded software and hardware consulting services
http://consulting.zylin.com
### Eclipse Workspace Patch 1.0
#P openocd
Index: src/jtag/jtag.c
===
--- src/jtag/jtag.c (revision 1750)
+++ src/jtag/jtag.c (working copy)
@@ -2889,9 +2889,11 @@
}
}
 
-   fields = malloc(sizeof(scan_field_t) * argc / 2);
+   int num_fields= num_fields;
+
+   fields = malloc(sizeof(scan_field_t) * num_fields);
 
-   for (i = 0; i  argc / 2; i++)
+   for (i = 0; i  num_fields; i++)
{
tap = jtag_TapByString( args[i*2] );
if (tap==NULL)
@@ -2901,19 +2903,20 @@
}
int field_size = tap-ir_length;
fields[i].tap = tap;
+   fields[i].num_bits = field_size;
fields[i].out_value = malloc(CEIL(field_size, 8));
buf_set_u32(fields[i].out_value, 0, field_size, 
strtoul(args[i*2+1], NULL, 0));
fields[i].in_value = NULL;
}
 
-   jtag_add_ir_scan(argc / 2, fields, TAP_INVALID);
+   jtag_add_ir_scan(num_fields, fields, TAP_INVALID);
/* did we have an endstate? */
if (endstate != TAP_INVALID)
jtag_add_end_state(endstate);
 
jtag_execute_queue();
 
-   for (i = 0; i  argc / 2; i++)
+   for (i = 0; i  num_fields; i++)
free(fields[i].out_value);
 
free (fields);
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development


Re: [Openocd-development] fix ancient bug SEGFAULT in irscan

2009-05-12 Thread Andreas Fritiofson
On Tue, May 12, 2009 at 8:18 AM, Øyvind Harboe oyvind.har...@zylin.com wrote:
 I couldn't believe my eyes when I saw what the bug was. irscan
 has *always* been broken. I checked as far back as svn 345.

 A couple of possible explanations:

 - irscan has never really been used
 - events have somehow conspired to hide the bugs
 - I'm missing something

 Known problems in irscan:

 - does not support 32 bit fields(?). This maybe a problem for
 omap devices(?)
 - why not reuse the new drscan code?


I may be stupid and/or tired, but what does this mean?

int num_fields= num_fields;

--Andreas
___
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development