Hmm, things seems to be more suble :-) I have tried a trick with using int *a; fun(int* &a); and it indeed works but the address is trimmed no matter what type "a" is (int*, long*, void*) and this causes problems.
21 int a1=0, a2=0; (gdb) s 22 double *a3; (gdb) 23 a3=NULL; (gdb) f1 (pf11=0x7fffffffe71c, pf12=0x7fffffffe718, pf13=0x7fffffffe710) at pointertest.c:17 17 return f2(pf11, pf12, pf13); (gdb) f2 (pf21=0x7fffffffe71c, pf22=0x7fffffffe718, pf23=0x7fffffffe710) at pointertest.c:6 6 stuff=calloc(1,sizeof(int)); (gdb) 7 if (!stuff) exit(-1); (gdb) 8 *stuff=0xDEADBEEF; (gdb) 9 printf("stuff[@%X]=%X\n", stuff, *stuff); (gdb) p/x stuff $1 = 0x800a04090 (gdb) p/x *stuff $2 = 0xdeadbeef (gdb) s stuff[@A04090]=DEADBEEF 10 *pf21=stuff; (gdb) 11 *pf22=*stuff; The most important lines below: (gdb) 12 *pf23=&stuff; (gdb) 13 return 0; (gdb) p/x pf23 $3 = 0x7fffffffe710 (gdb) p/x *pf23 $4 = 0xffffe6b0 (gdb) p/x &stuff $5 = 0x7fffffffe6b0 &stuff is the address of the memory location. I want to write that location to my pointer, but its trimmed although variable IS a pointer. Maybe this is because of a type.... The most interesting part is the "*variable=value" construct because without this we cannot get data out of the function. Even if we change the address contained within a pointer variable we will get the data from an old address!!! Note that below I did not use *variable=value but simple variable=value, variable changed but it still points to the old memory location (0x00 instead 0xdeadbeef) (gdb) p/x &stuff $1 = 0x7fffffffe6b0 (gdb) p/x stuff $2 = 0x800a04090 (gdb) p/x *stuff $3 = 0xdeadbeef (gdb) s stuff[@A04090]=DEADBEEF 10 *pf21=stuff; (gdb) 11 *pf22=*stuff; (gdb) 12 pf23=&stuff; (gdb) 13 return 0; (gdb) p/x &pf23 $4 = 0x7fffffffe698 (gdb) p/x pf23 $5 = 0x7fffffffe6b0 (gdb) p/x *pf23 $6 = 0x0 I think this is some memory corruption protection mechanism implemented by a compiler... Well I have to live with double pointers ;-P -- CeDeROM, SQ7MHZ, http://www.tomek.cedro.info _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development