Topic
15 replies Latest Post - ‏2013-02-08T02:08:37Z by kmisono
Saruton
Saruton
111 Posts
ACCEPTED ANSWER

Pinned topic Debugging C++ primitive operator using gdb

‏2013-01-26T15:37:58Z |
Hi ALL,
I'm now studying how to debug through gdb with a simple standalone application containing C++ primitive operator. I cannot submit any gdb command in gdb session. What is wrong in the setting and operations?

<Application summary>
Beacon --> Custom --> Primitive Operator --> Custom --> FileSink

<SPL compile option>
I specified options -x '-O0 -g' in 'Additional SPL compiler option' on standalone configuration. (I used passed question as reference: https://www.ibm.com/developerworks/forums/thread.jspa?messageID=14695040&#14695040)
'Compiler invocation' displays sc -M Main --output-directory=output/Main/Standalone --data-directory=data -T -g -x -Oo -g.

<Operations>
1. Launched the application from Eclipse.
2. sdb window was launched in the new window and (sdb) prompt was displayed.
3. Set an breakpoint at an input port of target primitive operator. Probe point was 0.
4. Ran "g" command to start the application, then application stopped at the probe point 0. An arrival tuple was displayed.
5. Entered "gdb 0" command. gdb was launched in another window and a series of message is displayed, which ends as follows:


Reading symbols from /usr/lib64/gconv/ISO8859-1.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib64/gconv/ISO8859-1.so
Reading symbols from /home/streamsadmin/workspace/DebuggerStudy/output/Main/Standalone/bin/Main-a.dpe...done.
Loaded symbols for /home/streamsadmin/workspace/DebuggerStudy/output/Main/Standalone/bin/Main-a.dpe
Reading symbols from /opt/ibm/InfoSphereStreams/system/impl/lib/libstreams-stdtk-runtime.so.0...(no debugging symbols found)...done.
Loaded symbols for /opt/ibm/InfoSphereStreams/system/impl/lib/libstreams-stdtk-runtime.so.0
0x0000003c572080ad in pthread_join () from /lib64/libpthread.so.0
Can't find member of namespace, class, struct, or union named "SPL::MyConverter_Base::processRaw (SPL::Punctuation const&, unsigned int)"
Hint: try 'SPL::MyConverter_Base::processRaw (SPL::Punctuation const&, unsigned int)<TAB> or 'SPL::MyConverter_Base::processRaw (SPL::Punctuation const&, unsigned int)<ESC-?>
(Note leading single quote.)
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]
Can't find member of namespace, class, struct, or union named "SPL::MyConverter_Base::processRaw (SPL::Tuple&, unsigned int)"
Hint: try 'SPL::MyConverter_Base::processRaw (SPL::Tuple&, unsigned int)<TAB> or 'SPL::MyConverter_Base::processRaw (SPL::Tuple&, unsigned int)<ESC-?>
(Note leading single quote.)
Make breakpoint pending on future shared library load? (y or [n]) [answered N; input not from terminal]


The last row prompts me to enter "y" or "n", but at that time, key input was available on (sdb), and I couldn't enter any commands in (gdb). If I enter "c" command, the application continues the procedure without stop in the primitive operator.

How can I set breakpoints in the primitive operator?

I would appreciate your help.

Thanks,
  • hnasgaard
    hnasgaard
    200 Posts
    ACCEPTED ANSWER

    Re: Debugging C++ primitive operator using gdb

    ‏2013-01-27T17:45:07Z  in response to Saruton
    SDB is not used to debug primitive operators with gdb. You need to add a config wrapper : nrgdb; in the operator you wish to debug. When the application is submitted a gdb window will open and it will stop at a predefined breakpoint. In that window you can set geb breakpoints in your operator code and then enter 'c' to continue.
    • Saruton
      Saruton
      111 Posts
      ACCEPTED ANSWER

      Re: Debugging C++ primitive operator using gdb

      ‏2013-01-28T16:12:21Z  in response to hnasgaard
      I appreciate your advice.
      At first, I have already tried to specify "config wrapper: gdb" to Main composite as follows (standalone mode):

      composite Main()
      {
      graph
      .....;
      config
      wrapper: gdb;
      }

      But in this case, sdb opened another window, but it doesn't stop at the beginning and runs through the application. Without "config wrapper: gdb;", sdb can stop at the beginning and I can create some breakpoints.

      Therefore, I also tried in distributed mode, but PEs, specifyed "config wrapper: gdb;", stopped and any logs didn't exist.

      Thanks & Regards,
      • hnasgaard
        hnasgaard
        200 Posts
        ACCEPTED ANSWER

        Re: Debugging C++ primitive operator using gdb

        ‏2013-01-28T16:20:58Z  in response to Saruton
        Can you try config wrapper : nrgdb;
        • Saruton
          Saruton
          111 Posts
          ACCEPTED ANSWER

          Re: Debugging C++ primitive operator using gdb

          ‏2013-01-31T04:57:03Z  in response to hnasgaard
          Thanks for your suggestion.
          I tried to specify "nrgdb" not only to each operator, but also Main composite itself.
          But in both cases, all PEs are unhealthy.
          I checked log files, but there is nothing in PE logs.

          Regards,
          • hnasgaard
            hnasgaard
            200 Posts
            ACCEPTED ANSWER

            Re: Debugging C++ primitive operator using gdb

            ‏2013-01-31T12:46:05Z  in response to Saruton
            Did the xterm windows open at a gdb prompt? You would need to enter 'c' in each to start the PE.
            • laurieaw
              laurieaw
              72 Posts
              ACCEPTED ANSWER

              Re: Debugging C++ primitive operator using gdb

              ‏2013-01-31T13:30:50Z  in response to hnasgaard
              What is the setting for SELinux? Enter /usr/sbin/getenforce from the command line.
              • Saruton
                Saruton
                111 Posts
                ACCEPTED ANSWER

                Re: Debugging C++ primitive operator using gdb

                ‏2013-02-01T02:34:24Z  in response to laurieaw
                SELinux is disabled.


                root@myhost ~# /usr/sbin/getenforce
                Disabled

            • Saruton
              Saruton
              111 Posts
              ACCEPTED ANSWER

              Re: Debugging C++ primitive operator using gdb

              ‏2013-02-01T02:32:29Z  in response to hnasgaard
              With wrapper config, xterm window at gdb prompt doesn't open. When I remove wrapper config from spl file, gdb prompt on xterm window opens.
              • hnasgaard
                hnasgaard
                200 Posts
                ACCEPTED ANSWER

                Re: Debugging C++ primitive operator using gdb

                ‏2013-02-01T19:32:56Z  in response to Saruton
                I'm not sure what is wrong here. I tried an experiment and, in when I submit my sample app the xterm window opens. If I do a streamtool lspes the PE shows healthy. Here's the code for a small sample that should open the xterm. Can you try that? If it doesn't open the window, can you capture the logs, streamtool getlog, and attach the logs to the forum.

                
                composite Main() 
                { graph stream<int32 i> Beat = Beacon() 
                { config wrapper : nrgdb; 
                } 
                }
                
                • Saruton
                  Saruton
                  111 Posts
                  ACCEPTED ANSWER

                  Re: Debugging C++ primitive operator using gdb

                  ‏2013-02-04T09:12:30Z  in response to hnasgaard
                  Thanks for a reply.
                  I'm going to attach StreamsLogs.tgz which is output of 'streamtool getlog' command.
                  On this job, I specified 'Debug application with SDB' to Distributed Mode configuration and PE was unhealthy.
                  I will greatly appreciate your further support.
                  Thanks a lot!
                  • hnasgaard
                    hnasgaard
                    200 Posts
                    ACCEPTED ANSWER

                    Re: Debugging C++ primitive operator using gdb

                    ‏2013-02-04T12:55:34Z  in response to Saruton
                    I see the following error in one of the logs: xterm Xt error: Can't open display: myhost.localdomain:0.0. I think that may be the root of your problem. If you try running xterm from a command line on myhost what happens?
                    • Saruton
                      Saruton
                      111 Posts
                      ACCEPTED ANSWER

                      Re: Debugging C++ primitive operator using gdb

                      ‏2013-02-05T14:32:05Z  in response to hnasgaard
                      Thanks for your continuous support.

                      I tried to run xterm command on myhost's terminal window.
                      xterm window opened from terminal window and command prompt was displayed (I think this is a normal behavior...), but the source terminal window displayed the following warning message.


                      Warning: Cannot convert string "nil2" to type FontStruct
                      xterm: cannot load font -misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1


                      Does this font loading problem cause the problem?

                      Thanks,
                      • hnasgaard
                        hnasgaard
                        200 Posts
                        ACCEPTED ANSWER

                        Re: Debugging C++ primitive operator using gdb

                        ‏2013-02-07T12:02:45Z  in response to Saruton
                        I don't think this problem would be caused by the font warning. Another question: what is the setting of the DISPLAY environment variable?
                  • kmisono
                    kmisono
                    4 Posts
                    ACCEPTED ANSWER

                    Re: Debugging C++ primitive operator using gdb

                    ‏2013-02-08T02:01:41Z  in response to Saruton
                    in hc.stderror:
                    >xterm Xt error: Can't open display: myhost.localdomain:0.0

                    I think that this error is caused by X11 configration.
                    Xorg may be executing with -nolisten option.

                    Check following command.
                    netstat -an | grep 6000

                    6000: listen port for X

                    Try to add "DisallowTCP=false" under the security section in the /etc/gdm/custom.conf.

                    eg.
                    ...
                    daemon
                    security
                    DisallowTCP=false
                    xdmcp

                    Finally, restart X.

                    I think if you were able to run the following command, and probably all right.
                    xclock -display myhost.localdomain:0.0

                    K. Misono
                    • kmisono
                      kmisono
                      4 Posts
                      ACCEPTED ANSWER

                      Re: Debugging C++ primitive operator using gdb

                      ‏2013-02-08T02:08:37Z  in response to kmisono
                      May also need to set the following.

                      xxx@yyyy ~$ cat ~/.ssh/config
                      ForwardX11 yes