Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-05 Thread Hiroshi Ito
> bash-3.2$ svn diff jtag.c > Index: jtag.c > === > --- jtag.c(revision 1204) > +++ jtag.c(working copy) this works fine, on my board. thanks. Hiroshi Ito Media Lab. Inc., URL http://www.mlb.co.jp ( Sorry, Japanese

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-04 Thread Michael Schwingen
Duane Ellis wrote: > micheal> [c requires aligned pointers] > > No, The C standard states it is implementation defined, i don't have a > copy handy to quote chapter & verse. I can't find it either. What I found was (in C99): 6.5.3.4: The implementation of the alloc function should ensure that its

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-03 Thread Duane Ellis
I checked the following in just now -Duane. bash-3.2$ svn diff jtag.c Index: jtag.c === --- jtag.c(revision 1204) +++ jtag.c(working copy) @@ -463,6 +463,39 @@ int offset; u8 *t; +/* + * WARNING: + *

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-03 Thread Duane Ellis
duane> [restating the problem differently to explain it] Rick Altherr> Thus, not only is the actual fix necessary, Rick Altherr> but a nice big comment describing the problem is appropriate as well. Always helpful to explain a tricky piece of code bit more in comments. rick Altherr> Attached

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-02 Thread Rick Altherr
On Dec 2, 2008, at 8:35 PM, Duane Ellis wrote: Hiroshi san, What was the original complaint? If I understand correctly, the problem was this: == cmd_que_allocate() - returns an un-aligned pointer. == Is that correct? If so - the cause, and solution is utterly simple, an

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-02 Thread Duane Ellis
rick> This doesn't change the pointer returned by cmd_queue_alloc() at all. the problem I believe is the *NEXT* allocation that is failing, after an "odd-sized" request, you get an odd aligned pointer. Two odd requests - should give you an even.. (sort of, not exactly, it has to be 4 bytes her

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-02 Thread Duane Ellis
Hiroshi san, What was the original complaint? If I understand correctly, the problem was this: == cmd_que_allocate() - returns an un-aligned pointer. == Is that correct? If so - the cause, and solution is utterly simple, and is as follows: The solution is to *ROUND*UP* all re

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-02 Thread Michael Schwingen
Rick Altherr wrote: > Ironically, my day job has been exclusively on non-x86 platforms for > years and only recently started with x86. > > Pointers to data types should be aligned such that the data type is > naturally aligned. That would mean that a 16-bit type should be > 16-bit aligned. The qu

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-02 Thread Rick Altherr
On Dec 2, 2008, at 10:03 AM, Michael Schwingen wrote: Rick Altherr wrote: I'm also not entirely sure that a structure must always be aligned. I'm aware that some architectures will trap if an unaligned access is encountered, but the OS should catch the trap and handle the unaligned access c

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-02 Thread Michael Schwingen
Rick Altherr wrote: > I'm also not entirely sure that a structure must always be aligned. > I'm aware that some architectures will trap if an unaligned access is > encountered, but the OS should catch the trap and handle the unaligned > access correctly. No. AFAIK, C requires pointers to be ali

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-02 Thread Rick Altherr
I think a combination of your two approaches might be more appropriate. Let's introduce a new function cmd_queue_allocate_aligned() that does the alignment as well as the allocation. The benefit is that only cases where alignment is necessary can use the new function, but they still only

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-02 Thread Hiroshi Ito
> I'm also not entirely sure that a structure must always be aligned. C language, one of what is required is, member of structure should aligne to natively accessable. # I think... but I'm not sure... > I'm aware that some architectures will trap if an unaligned access is > encountere

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-02 Thread Hiroshi Ito
> > How about this patch. this also works. > > > > Is it acceptable ? > > I change the code. > this is more readable. same, but revert unnecessary change. Hiroshi Ito Media Lab. Inc., URL http://www.mlb.co.jp ( Sorry, Japanese only. ) TEL +81-3-5294-7255 FAX +81-3-5294-7256 Index:

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-02 Thread Hiroshi Ito
> How about this patch. this also works. > > Is it acceptable ? I change the code. this is more readable. Hiroshi Ito Media Lab. Inc., URL http://www.mlb.co.jp ( Sorry, Japanese only. ) TEL +81-3-5294-7255 FAX +81-3-5294-7256 Index: src/jtag/jtag.c ===

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-02 Thread Hiroshi Ito
How about this patch. this also works. Is it acceptable ? > On Dec 2, 2008, at 12:46 PM, Hiroshi Ito wrote: > > > I'm running openocd on EP9307(arm925t) CPU, as a HOST. > > and target is EP9307 and ARM926t with EP9307 GPIO. > > > > revision 1183 cause seg fault. > > The problem is, cmd_queue_al

Re: [Openocd-development] PATCH:fix SIGSEGV

2008-12-01 Thread Rick Altherr
On Dec 2, 2008, at 12:46 PM, Hiroshi Ito wrote: I'm running openocd on EP9307(arm925t) CPU, as a HOST. and target is EP9307 and ARM926t with EP9307 GPIO. revision 1183 cause seg fault. The problem is, cmd_queue_alloc returns unaligned pointer. but it is used as a pointer to structure. This pa

[Openocd-development] PATCH:fix SIGSEGV

2008-12-01 Thread Hiroshi Ito
I'm running openocd on EP9307(arm925t) CPU, as a HOST. and target is EP9307 and ARM926t with EP9307 GPIO. revision 1183 cause seg fault. The problem is, cmd_queue_alloc returns unaligned pointer. but it is used as a pointer to structure. This patch fix it. and it is working. Index: src/jtag/jtag.