Differences between revisions 2 and 5 (spanning 3 versions)
Revision 2 as of 2016-02-11 02:37:51
Size: 471
Editor: AndrewStone
Comment:
Revision 5 as of 2016-02-12 16:12:20
Size: 1657
Editor: AndrewStone
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:

=== Debugging the initial startup of your application ===
 
 * '''Be tolerant of long instantiation times'''
The SAFplus AMF will restart an application that exceeds its "instantiation timeout" (30 seconds by default). This will disrupt debugging efforts. To fix this issue, change the component's instantiation timeout. This can be accomplished in a variety of ways... to do it via XML file, look for your the definition in your component (tags: component->instantiate->timeout) and change it to a very large number. For example:
{{{#!highlight xml
 <Component name="mycomp">
...
      <instantiate>
        <command>./mycomp</command>
        <timeout>1000000000</timeout>
      </instantiate>
...
 </Component>
}}}

Line 6: Line 23:
{{{ {{{#!highlight bash
Line 8: Line 25:
echo /usr/bin/gnome-terminal --window --command "gdb --args $0.bin $1 $2 $3 $4 $5 $6 $7 $8 $9"
/usr/bin/gnome-terminal --window --command "gdb --args $0.bin $1 $2 $3 $4 $5 $6 $7 $8 $9"
echo /usr/bin/gnome-terminal --disable-factory --window --command "gdb --args $0.bin $1 $2 $3 $4 $5 $6 $7 $8 $9"
exec /usr/bin/gnome-terminal --disable-factory --window --command "gdb --args $0.bin $1 $2 $3 $4 $5 $6 $7 $8 $9"
Line 12: Line 29:
Now when SAFplus starts your program, it will actually start a window and run your program inside gdb. Now when SAFplus AMF starts your program, it will pop up a terminal window and run your program inside gdb. It is important that the process id (PID) of the terminal be the same PID that SAFplus AMF started so that it can monitor your program. This is the purpose of the "exec" prefix and the --disable-factory flag. If your process forks another process and quits, the AMF will see this as a failure (your process quit, after all) and restart it. This can result in repeated restarts.

Debugging

Debugging the initial startup of your application

  • Be tolerant of long instantiation times

The SAFplus AMF will restart an application that exceeds its "instantiation timeout" (30 seconds by default). This will disrupt debugging efforts. To fix this issue, change the component's instantiation timeout. This can be accomplished in a variety of ways... to do it via XML file, look for your the definition in your component (tags: component->instantiate->timeout) and change it to a very large number. For example:

   1  <Component name="mycomp">
   2 ...
   3       <instantiate>
   4         <command>./mycomp</command>
   5         <timeout>1000000000</timeout>
   6       </instantiate>
   7 ...
   8  </Component>
  • Start gdb instead of your program

Rename your program 'X' to X.bin. Next create an executable script X with this content:

   1 #!/bin/bash
   2 echo /usr/bin/gnome-terminal --disable-factory --window --command "gdb --args $0.bin $1 $2 $3 $4 $5 $6 $7 $8 $9"
   3 exec /usr/bin/gnome-terminal --disable-factory --window --command "gdb --args $0.bin $1 $2 $3 $4 $5 $6 $7 $8 $9"

Now when SAFplus AMF starts your program, it will pop up a terminal window and run your program inside gdb. It is important that the process id (PID) of the terminal be the same PID that SAFplus AMF started so that it can monitor your program. This is the purpose of the "exec" prefix and the --disable-factory flag. If your process forks another process and quits, the AMF will see this as a failure (your process quit, after all) and restart it. This can result in repeated restarts.

SAFplus: SAFplus Management Developer's Guide (last edited 2017-09-18 09:07:52 by HungTa)