I get a seg fault when I try to watch a string.
#include <memory.h> // for memset
#include <string>
using namespace std;
const unsigned kuiConfigFileNameMaxLength = 128;
int main(int argc, char* argv[])
{
int iErr = 0;
char cConfigFileName [kuiConfigFileNameMaxLength];
memset( (void*)cConfigFileName , 0, kuiConfigFileNameMaxLength );
// Get input file name
if ( strlen( (const char *) argv[1] ) > kuiConfigFileNameMaxLength )
{
iErr = 1;
}
else
{
memcpy( (void*)cConfigFileName, (const void*)argv[1], strlen( (const char *) argv[1] ));
}
string strConfigFileName( (const char*)(cConfigFileName), strlen( (const char *)cConfigFileName) );
return iErr;
}
LD_LIBRARY_PATH=.:/usr/physics/root/pro/lib:
Command-line: /usr/bin/gdb -nx -fullname -quiet -args Debug/BuildCrocusCfgFile
Working dir : /home/rousseau/DSP/codeBlock/codeBlockTst1/
Reading symbols from /home/rousseau/DSP/codeBlock/codeBlockTst1/Debug/BuildCrocusCfgFile...
done.
(gdb)
> set prompt >>>>>>cb_gdb:
Executing: xterm -T 'Program Console' -e sleep 82690
>>>>>>cb_gdb:
> show version
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>.
>>>>>>cb_gdb:
> set confirm off
>>>>>>cb_gdb:
> set width 0
>>>>>>cb_gdb:
> set height 0
>>>>>>cb_gdb:
> set breakpoint pending on
>>>>>>cb_gdb:
> set print asm-demangle on
>>>>>>cb_gdb:
> set unwindonsignal on
>>>>>>cb_gdb:
> set disassembly-flavor intel
>>>>>>cb_gdb:
> catch throw
Function "__cxa_throw" not defined.
Catchpoint 1 (throw)
>>>>>>cb_gdb:
> source /usr/share/codeblocks/scripts/stl-views-1.0.3.gdb
>>>>>>cb_gdb:
> directory /home/rousseau/DSP/codeBlock/codeBlockTst1/
>>>>>>cb_gdb:
> set args S:\svn\ALICE\windows\codeBlockTst1
>>>>>>cb_gdb:
> break "/home/rousseau/DSP/codeBlock/codeBlockTst1/BuildCrocusCfgFile.cpp:16"
Breakpoint 2 at 0x400916: file /home/rousseau/DSP/codeBlock/codeBlockTst1/BuildCrocusCfgFile.cpp, line 16.
>>>>>>cb_gdb:
Executing: ps x -o tty,pid,command
PS result: pts/48 7344 ps x -o tty,pid,command
PS result: pts/6 7343 sleep 82690
TTY is[/dev/pts/6]
GetConsoleTTY[/dev/pts/6]ConsolePid[7341]
> tty /dev/pts/6
Queued:[tty /dev/pts/6]
>>>>>>cb_gdb:
> run
Breakpoint 2, main (argc=2, argv=0x7fffffffea28) at /home/rousseau/DSP/codeBlock/codeBlockTst1/BuildCrocusCfgFile.cpp:16
/home/rousseau/DSP/codeBlock/codeBlockTst1/BuildCrocusCfgFile.cpp:16:351:beg:0x400916
>>>>>>cb_gdb:
> info locals
iErr = 0
cConfigFileName = "\000\000\000\000\000\000\000\000\004\005@\000\000\000\000\000\070\226.", '\000' <se r\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀堀尀㈀㜀㐀尀㌀㌀㌀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 昀漀椀猀㸀∀尀㈀㐀 Ⰰ 尀㈀㔀㔀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 琀尀㈀ 㜀尀㌀㌀㘀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀㬀尀愀䀀尀 尀 尀 尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 尀㈀ 㔀尀渀䀀尀 尀 尀 尀 尀 ⠀尀㌀㔀㈀尀㌀㜀㜀尀㌀㜀㜀尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀尀 尀 尀 尀 ∀
strConfigFileName = {
static npos = <optimized out>,
_M_dataplus = {
<std::allocator<char>> = {
<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
_M_p = 0x1ffffffff <Address 0x1ffffffff out of bounds>
}
}
>>>>>>cb_gdb:
> info args
argc = 2
argv = 0x7fffffffea28
>>>>>>cb_gdb:
> whatis argv[1]
type = char *
>>>>>>cb_gdb:
> output argv[1]
0x7fffffffec95 "S:svnALICEwindowscodeBlockTst1">>>>>>cb_gdb:
> whatis cConfigFileName
type = char [128]
>>>>>>cb_gdb:
> output cConfigFileName
"\000\000\000\000\000\000\000\000\004\005@\000\000\000\000\000\070\226.", '\000' <se r\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀堀尀㈀㜀㐀尀㌀㌀㌀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 昀漀椀猀㸀∀尀㈀㐀 Ⰰ 尀㈀㔀㔀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 琀尀㈀ 㜀尀㌀㌀㘀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀㬀尀愀䀀尀 尀 尀 尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 尀㈀ 㔀尀渀䀀尀 尀 尀 尀 尀 ⠀尀㌀㔀㈀尀㌀㜀㜀尀㌀㜀㜀尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀尀 尀 尀 尀 ∀>>>>>>cb_gdb:
> bt 30
#0 main (argc=2, argv=0x7fffffffea28) at /home/rousseau/DSP/codeBlock/codeBlockTst1/BuildCrocusCfgFile.cpp:16
>>>>>>cb_gdb:
> info locals
iErr = 0
cConfigFileName = "\000\000\000\000\000\000\000\000\004\005@\000\000\000\000\000\070\226.", '\000' <se r\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀堀尀㈀㜀㐀尀㌀㌀㌀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 昀漀椀猀㸀∀尀㈀㐀 Ⰰ 尀㈀㔀㔀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 琀尀㈀ 㜀尀㌀㌀㘀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀㬀尀愀䀀尀 尀 尀 尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 尀㈀ 㔀尀渀䀀尀 尀 尀 尀 尀 ⠀尀㌀㔀㈀尀㌀㜀㜀尀㌀㜀㜀尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀尀 尀 尀 尀 ∀
strConfigFileName = {
static npos = <optimized out>,
_M_dataplus = {
<std::allocator<char>> = {
<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
_M_p = 0x1ffffffff <Address 0x1ffffffff out of bounds>
}
}
>>>>>>cb_gdb:
> info args
argc = 2
argv = 0x7fffffffea28
>>>>>>cb_gdb:
> whatis argv[1]
type = char *
>>>>>>cb_gdb:
> output argv[1]
0x7fffffffec95 "S:svnALICEwindowscodeBlockTst1">>>>>>cb_gdb:
> whatis cConfigFileName
type = char [128]
>>>>>>cb_gdb:
> output cConfigFileName
"\000\000\000\000\000\000\000\000\004\005@\000\000\000\000\000\070\226.", '\000' <se r\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀堀尀㈀㜀㐀尀㌀㌀㌀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 昀漀椀猀㸀∀尀㈀㐀 Ⰰ 尀㈀㔀㔀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 琀尀㈀ 㜀尀㌀㌀㘀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀㬀尀愀䀀尀 尀 尀 尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 尀㈀ 㔀尀渀䀀尀 尀 尀 尀 尀 ⠀尀㌀㔀㈀尀㌀㜀㜀尀㌀㜀㜀尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀尀 尀 尀 尀 ∀>>>>>>cb_gdb:
> whatis strConfigFileName
type = std::string
>>>>>>cb_gdb:
> output strConfigFileName.c_str()[0]@strConfigFileName.size()
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off".
Evaluation of the expression containing the function
(std::string::size() const) will be abandoned.
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b77dd3 in std::string::size() const () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
>>>>>>cb_gdb:
> info locals
iErr = 0
cConfigFileName = "\000\000\000\000\000\000\000\000\004\005@\000\000\000\000\000\070\226.", '\000' <se r\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀堀尀㈀㜀㐀尀㌀㌀㌀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 昀漀椀猀㸀∀尀㈀㐀 Ⰰ 尀㈀㔀㔀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 琀尀㈀ 㜀尀㌀㌀㘀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀㬀尀愀䀀尀 尀 尀 尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 尀㈀ 㔀尀渀䀀尀 尀 尀 尀 尀 ⠀尀㌀㔀㈀尀㌀㜀㜀尀㌀㜀㜀尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀尀 尀 尀 尀 ∀
strConfigFileName = {
static npos = <optimized out>,
_M_dataplus = {
<std::allocator<char>> = {
<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
members of std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider:
_M_p = 0x1ffffffff <Address 0x1ffffffff out of bounds>
}
}
>>>>>>cb_gdb:
> info args
argc = 2
argv = 0x7fffffffea28
>>>>>>cb_gdb:
> whatis argv[1]
type = char *
>>>>>>cb_gdb:
> output argv[1]
0x7fffffffec95 "S:svnALICEwindowscodeBlockTst1">>>>>>cb_gdb:
> whatis cConfigFileName
type = char [128]
>>>>>>cb_gdb:
> output cConfigFileName
"\000\000\000\000\000\000\000\000\004\005@\000\000\000\000\000\070\226.", '\000' <se r\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀堀尀㈀㜀㐀尀㌀㌀㌀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 昀漀椀猀㸀∀尀㈀㐀 Ⰰ 尀㈀㔀㔀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 琀尀㈀ 㜀尀㌀㌀㘀尀㌀㘀㜀尀㌀㜀㜀尀㜀㜀尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀∀Ⰰ ✀尀 ✀ 㰀猀攀 爀\000\377\377\377\377\377\377\377烿\000\377\377\377\377\377\377\377瓿攀 ㌀ 昀漀椀猀㸀Ⰰ ∀㬀尀愀䀀尀 尀 尀 尀 尀 尀 尀 尀 尀 尀㌀㜀㜀尀㜀㜀尀 尀 尀㈀ 㔀尀渀䀀尀 尀 尀 尀 尀 ⠀尀㌀㔀㈀尀㌀㜀㜀尀㌀㜀㜀尀㌀㜀㜀尀㜀㜀尀 尀 䀀尀渀䀀尀 尀 尀 尀 ∀>>>>>>cb_gdb:
> whatis strConfigFileName
type = std::string
>>>>>>cb_gdb:
> output strConfigFileName.c_str()[0]@strConfigFileName.size()
The program being debugged was signaled while in a function called from GDB.
GDB has restored the context to what it was before the call.
To change this behavior use "set unwindonsignal off".
Evaluation of the expression containing the function
(std::string::size() const) will be abandoned.
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7b77dd3 in std::string::size() const () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
>>>>>>cb_gdb:
> bt 30
#0 main (argc=2, argv=0x7fffffffea28) at /home/rousseau/DSP/codeBlock/codeBlockTst1/BuildCrocusCfgFile.cpp:16
>>>>>>cb_gdb: