Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Strange problen with sprintf on PPC: (5 Items)
   
Strange problen with sprintf on PPC  
Hello,

below is a gdb session showing that problem on a Lite5200 EVB.
What could be the problem ??

# make -f mApp
qcc -g -Vgcc_ntoppcbe -Wall -I. -I../../examples/m1 -I../../canopen/include -I../../drivers/shar_inc -I../../drivers/
generic -o co_appl  main.c -L obj -l co -l appl -l co -l CAN
# ntoppc-gdb
GNU gdb 5.0 (UI_OUT)
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=x86-pc-nto-qnx --target=ntoppc".
(gdb) target qnx 192.168.178.77:10000
Remote debugging using 192.168.178.77:10000
(gdb) set qnxremotecwd /
(gdb) upload co_appl  co_appl
(gdb) sy  co_appl
Reading symbols from co_appl...done.
(gdb) b main
Breakpoint 1 at 0x48040b60: file main.c, line 246.
(gdb) ru  co_appl
Starting program:  co_appl
(gdb) c
Continuing.

Breakpoint 1, main (argc=???, argv=???) at main.c:246
246     {
(gdb) n
main (argc=1, argv=0x4803fe84) at main.c:249
249         BOOL_T              err = CO_FALSE; /* error flag */
(gdb)
259             ThreadCtl( _NTO_TCTL_IO, 0 );
(gdb)
261         setOptions(CO_EXAMPLE_ARGS);
(gdb)
267         lNodeId = NODE_ID;
(gdb)
271             memset(CAN_resmgr_name, 0x00, 32);
(gdb)
272             sprintf(CAN_resmgr_name, "/dev/%s%d", can_device, curr_channel);
(gdb)

Program received signal SIGSEGV, Segmentation fault.
0xfe34bfd8 in ?? () from /ppcbe/lib/libc.so.2
(gdb) print can_device
$1 = "CANDRV", '\000' <repeats 23 times>
(gdb) print curr_channel
$2 = 1
(gdb)                                                      
Re: Strange problen with sprintf on PPC  
On Mon, Jul 14, 2008 at 01:06:33PM -0400, Armin Steinhoff wrote:
> 
> Hello,
> 
> below is a gdb session showing that problem on a Lite5200 EVB.
> What could be the problem ??
> 
> # make -f mApp
> qcc -g -Vgcc_ntoppcbe -Wall -I. -I../../examples/m1 -I../../canopen/include -I../../drivers/shar_inc -I../../drivers/
generic -o co_appl  main.c -L obj -l co -l appl -l co -l CAN
> # ntoppc-gdb
> GNU gdb 5.0 (UI_OUT)
> Copyright 2000 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "--host=x86-pc-nto-qnx --target=ntoppc".
> (gdb) target qnx 192.168.178.77:10000
> Remote debugging using 192.168.178.77:10000
> (gdb) set qnxremotecwd /
> (gdb) upload co_appl  co_appl
> (gdb) sy  co_appl
> Reading symbols from co_appl...done.
> (gdb) b main
> Breakpoint 1 at 0x48040b60: file main.c, line 246.
> (gdb) ru  co_appl
> Starting program:  co_appl
> (gdb) c
> Continuing.
> 
> Breakpoint 1, main (argc=???, argv=???) at main.c:246
> 246     {
> (gdb) n
> main (argc=1, argv=0x4803fe84) at main.c:249
> 249         BOOL_T              err = CO_FALSE; /* error flag */
> (gdb)
> 259             ThreadCtl( _NTO_TCTL_IO, 0 );
> (gdb)
> 261         setOptions(CO_EXAMPLE_ARGS);
> (gdb)
> 267         lNodeId = NODE_ID;
> (gdb)
> 271             memset(CAN_resmgr_name, 0x00, 32);
> (gdb)
> 272             sprintf(CAN_resmgr_name, "/dev/%s%d", can_device, curr_channel);
> (gdb)
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0xfe34bfd8 in ?? () from /ppcbe/lib/libc.so.2
> (gdb) print can_device
> $1 = "CANDRV", '\000' <repeats 23 times>
> (gdb) print curr_channel
> $2 = 1
> (gdb)                                                      

Is curr_channel an int?

-seanb
Re: Strange problen with sprintf on PPC  
Yes,  curr_channel is an int.
The sprintf statement crashes also when the curr_channel varable is removed from that statement.

--Armin
Re: Strange problen with sprintf on PPC  
Problem solved ...

--Armin
Re: Strange problen with sprintf on PPC  
C'mon .. you can't just leave us hanging like that ... the suspense is
killing me ... what was the problem =;-)

Thomas

On Mon, Jul 14, 2008 at 5:00 PM, Armin Steinhoff <armin@steinhoff.de> wrote:

>
> Problem solved ...
>
> --Armin
>
>
> _______________________________________________
> QNX Momentics Community Support
> http://community.qnx.com/sf/go/post10507
>
>