User forums > Embedded development

Problem when "watching" std::string

(1/1)

thamurath:
Hi all .

First of all, i am not sure if this is the rightly forum so please sorry if not.

The question is: I am developing an application for an embedded system running debian etch over a powerpc. My pc runs debian etch also and i use codeblocks. Well, when i do remote debugging and try to watch a std::string programs start to receive SIGSEGV signals and evetually an SIGABRT.
At first i thought it was because i havent libstdc++-dbg pakage instaled but i have installed it ( both the "normal" and the cross ) and nothing changes.

Any help would be very appreciated!

Info:
S.O: debian etch
Codeblocks: svn5456
gcc 4.1.2
gdb 6.4.90
gdbserver 6.8
libstdc++6 4.1.21

Jenna:
This happens if you try to see the content of an unitialised std::string.

thamurath:
Thanks for reply, but i dont think so.

The following code is an example. I usually put a breakpoint at the first if line and then SIGSEGV is raised ( in my watch window is msg).
The signal didnt raise if the breakpoint is disable.

--- Code: ---void DiagnosticPutString(const unsigned short ai_sourceId,
                                                const unsigned short ai_diagCommIndex,
                                                const unsigned short ai_diagSessionIndex,
                                                const unsigned short ai_diagSectorIndex,
                                                const int ai_protocol,
                                                const int ai_errorCode,
                                                const std::string& ai_string)
            {
                static std::string msg ("");

                if ( !ai_string.empty() )
                {
                    msg = msg + ai_string;
                    if (
                            (ai_string.at(0) == '\n') ||
                            (ai_string.find("\r\n") != std::string::npos)
                        )
                    {
                        Log("DiagnosticPutString: "
                            << "\n sourceId: " << ai_sourceId
                            << "\n comIndex: " << ai_diagCommIndex
                            << "\n sessionIndex: " << ai_diagSessionIndex
                            << "\n sectorIndex: " << ai_diagSectorIndex
                            << "\n protocol: " << ai_protocol
                            << "\n errorCode: " << ai_errorCode
                            << "\n message: " << msg);
                        msg.clear();
                   }
                }

--- End code ---

Jenna:
gdb stops before the line where the breakpoint is set gets executed, that means msg is not initialised the first time you hit the breakpoint.

thamurath:
Thanks for your help.

Navigation

[0] Message Index

Go to full version