16 Replies Latest reply on Jul 25, 2011 1:23 AM by Anirudh Sasikumar

    ANT Debug

    Fredrick Backer

      I'm trying to use ANT with Flash Builder 4 to compile and debug.

       

      The compiling is the easy part but having trouble to get the debugger to work.

       

      I want to use ANT to Debug SWF file inside Flash Builder, so that breakpoints, console traces and everything works as it should.

       

       

      My script so far. Builds The *.as to *.swf and moves from bin-debug to deploy folder. How can I start a Flash Builder Debugger for the created SWF?

       

      <!-- this opens the file in Flash Debug Player, but Flash Builder IDE doesn't understand this? -->

      <exec executable="open" vmlauncher="true" spawn="false" failonerror="true">
           <arg line="-a '${flashPlayer}' '${DEPLOY_DIR}/${file}'" />
      </exec>

       

      <!-- to run, compiles and then open -->

      <target name="Compile level 1">
         
      <antcall target="compile flex file">
             
      <param name="file" value="GameOffice"/>
         
      </antcall>
         
      <antcall target="open player">
             
      <param name="file" value="GameOffice.swf"/>
         
      </antcall>
      </target>

      <!-- compile *.as to *.swf, move from bin-debug to deploy (to fix Flex SVN issues -->
      <target name="compile flex file">
         
      <mxmlc file="${SRC_DIR}/${file}.as" output="${BUILD_DIR}/${file}.swf"
             
      actionscript-file-encoding="UTF-8"
             
      keep-generated-actionscript="true"
             
      incremental="true"
             
      static-link-runtime-shared-libraries="true"
             
      show-actionscript-warnings="true"
             
      failonerror="true"
             
      debug="true"
             
      optimize="false">

             
      <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
             
      <source-path path-element="${FLEX_HOME}/frameworks" />

             
      <compiler.include-libraries dir="${basedir}/libs" append="true">
                 
      <include name="HelloThereLibGames.swc" />
                 
      <include name="HelloThereLibStructure.swc" />
                 
      <include name="HelloThereLibUtils.swc" />
             
      </compiler.include-libraries>

             
      <metadata description="Hello There Production">
                 
      <contributor name="Fredrick Bäcker" />
             
      </metadata>

         
      </mxmlc>
         
      <copy todir="${DEPLOY_DIR}" file="${BUILD_DIR}/${file}.swf"/>
      </target>
        • 1. Re: ANT Debug
          Anirudh Sasikumar Adobe Employee

          Hi,

           

          There's no ant task to launch provided by Eclipse. Unless you write your own, I don't see an easy way to do this.

           

          Here are the ant tasks that are provided by Eclipse: http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/ant_ec lipse_tasks.htm

           

          Thanks,

          Anirudh

          • 2. Re: ANT Debug
            Fredrick Backer Level 1

            Understand that eclipse doens't have anything but Flex SDK must have something (from ADOBE), must be able to run from the commandline?

             

            Looking into /Application/Adobe Flash Builder 4/sdks/{version}/bin there is a lot of tools.

            When compiling and debugging I'm guessing Flex uses the commandline to execute what to run, so there's must be a way to do the same but from an ANT script to have own control over it.

             

            cheers

            /Fredrick

            • 3. Re: ANT Debug
              Anirudh Sasikumar Adobe Employee

              Ah, that way yes. Look up the help documentation for fdb (command line debugger).

               

              The syntax is similar to gdb.

              • 4. Re: ANT Debug
                Fredrick Backer Level 1

                Tried the fdb, when running in terminal it works but I need to type continue all the time at startup.

                Problem here is that it starts up but when I think when terminal needs me to type continue it just stops. Look at the terminal output it opens the flash debugger but closes directly.

                 

                Any suggestions.

                 

                ANT

                   <target name="open player">
                        <echo>Launching '${DEPLOY_DIR}/${file}'...</echo>
                       
                        <exec executable="/bin/sh" failonerror="false">
                            <arg line="-a '${fdb}'" />
                            <arg line="run '${DEPLOY_DIR}/${file}'" />
                        </exec>
                       
                   </target>

                 

                 

                This is whats happening in the terminal.

                     [echo] Launching '/Users/macbookpro/Documents/Adobe Flash Builder 4/Coopervision/deploy/GameOffice.swf'...
                     [exec] Adobe fdb (Flash Player Debugger) [build 16076]
                     [exec] Copyright (c) 2004-2007 Adobe, Inc. All rights reserved.
                     [exec] Attempting to launch and connect to Player using URL
                     [exec] /Users/macbookpro/Documents/Adobe Flash Builder 4/Coopervision/deploy/GameOffice.swf
                     [exec] Player connected; session starting.
                     [exec] Set breakpoints and then type 'continue' to resume the session.
                     [exec] [SWF] Users:macbookpro:Documents:Adobe Flash Builder 4:Coopervision:deploy:GameOffice.swf - 1,796,757 bytes after decompression
                     [exec] Session already in progress
                     [exec] (fdb)

                • 5. Re: ANT Debug
                  Anirudh Sasikumar Adobe Employee

                  Try putting a file called .fdbinit in the current directory with the commands like continue, bt, etc.

                  • 6. Re: ANT Debug
                    Fredrick Backer Level 1

                    Don't really understand what to do with it, where to place it or how to run it?

                     

                    Some more info please.

                    Thanks

                    • 7. Re: ANT Debug
                      Anirudh Sasikumar Adobe Employee

                      Create a file called fdbinit.txt in a particular directory.

                       

                      Inside the file, put commands such as:

                       

                      continue

                       

                      Now, rename that file to .fdbinit (if you are on windows, you'd have to do this from the command prompt).

                       

                      In your ant script, cd to the directory with the file before calling fdb. Fdb will read the file and execute the commands one by one.

                       

                      Thanks,

                      Anirudh

                      • 8. Re: ANT Debug
                        Fredrick Backer Level 1

                        A little bit on the way but still one thing.

                         

                        I'm running my ANT script to tell the FDB to go

                        <exec executable="${fdb}" failonerror="true"></exec>

                         

                        In the folder where I execute (project root) i placed .fdbinit with the following code

                        run ./deploy/GameOffice.swf
                        continue
                        continue
                        continue

                         

                        I've even tried to run a shell script that only starts the fdb in the projet folder, but the results are the same.

                        Seems like that when flash has been loaded and is showing in the Flash Debug Player the Console terminates FDB and that will close the Flash window.

                         

                             [exec] Adobe fdb (Flash Player Debugger) [build 16076]
                             [exec] Copyright (c) 2004-2007 Adobe, Inc. All rights reserved.
                             [exec] Attempting to launch and connect to Player using URL
                             [exec] ./deploy/GameOffice.swf
                             [exec] Player connected; session starting.
                             [exec] Set breakpoints and then type 'continue' to resume the session.
                             [exec] [SWF] Users:macbookpro:Documents:Adobe Flash Builder 4:Coopervision:deploy:GameOffice.swf - 1,796,757 bytes after decompression
                             [exec] [trace] [class DebugMode] debug mode 31
                             [exec] Do you want to attempt to halt execution? (y or n) Not confirmed.
                             [exec] Do you want to attempt to halt execution? (y or n) Not confirmed.
                             [exec] Do you want to attempt to halt execution? (y or n) Not confirmed.
                             [exec] Do you want to attempt to halt execution? (y or n) Not confirmed.
                             [exec] Do you want to attempt to halt execution? (y or n) Not confirmed.
                             [exec] Do you want to attempt to halt execution? (y or n) Not confirmed.
                             [exec] Do you want to attempt to halt execution? (y or n) Not confirmed.
                             [exec] Do you want to attempt to halt execution? (y or n) Not confirmed.
                             [exec] [SWF] Users:macbookpro:Documents:Adobe Flash Builder 4:Coopervision:deploy:GameOffice.swf - 1,796,757 bytes after decompression
                             [exec] Do you want to attempt to halt execution? (y or n) Not confirmed.
                             [exec] [SWF] Users:macbookpro:Documents:Adobe Flash Builder 4:Coopervision:deploy:assets_office.swf - 254,511 bytes after decompression
                             [exec] Additional ActionScript code has been loaded from a SWF or a frame.
                             [exec] To see all currently loaded files, type 'info files'.
                             [exec] Set additional breakpoints as desired, and then type 'continue'.
                             [exec] (fdb)

                         

                         

                        Any suggestions on how to hold the script alive so it doens't close?

                        • 9. Re: ANT Debug
                          Anirudh Sasikumar Adobe Employee

                          fdb is supposed to stay alive till you manually exit from the prompt.

                           

                          Does it quit even if there is no .fdbinit file?

                          Are all the swf files the debug version? (FDB is sensitive when it comes to having a release SWF loaded).

                          • 10. Re: ANT Debug
                            Fredrick Backer Level 1

                            I've exported all files now to DEBUG SWF files.

                             

                            Tried to remove the .fdbinit file but then it closes faster.

                             

                            Did a simple terminal script debug.sh

                            #!/bin/bash
                            /Applications/Adobe\ Flash\ Builder\ 4/sdks/4.1.0.16076/bin/fdb

                             

                             

                            After a while I notice the problem.

                            The .fdbinit script doesn't seem to wait for input to type the command, it just types the commands from the file and doesn't care what comes back. So when the fdb halts and waiting for input (for e.g. external loaded file) I must input continue.

                             

                            So I filled the .fdbinit with a lot of lines of continue and with enought of them it started up and it shows in the Eclipse Console. Problem where that with not the correct amount I end up with the console flooded with : Do you want to attempt to halt execution? (y or n) Not confirmed.

                             

                            Just thinks it's sad that with the great compiler tool there should be a good way to do the same with debugging =(

                            Problem if manage to fix this I still have a lot of other files that I want to debug the same way in the project so this its not a solution at all.

                             

                             

                            Base of my  problem lies in bigger projects with multiple inputs and that the bin-debug isn't allowed to be checked in into SVN (post: http://forums.adobe.com/thread/774736?tstart=0)

                             

                            /fredrick

                            • 11. Re: ANT Debug
                              Anirudh Sasikumar Adobe Employee

                              Ah, that explains the problem you are facing.

                               

                              Could you try passing -unit as well?

                              • 12. Re: ANT Debug
                                Fredrick Backer Level 1

                                Sorry, don't know what that means =) I'm really a layman.

                                • 13. Re: ANT Debug
                                  Anirudh Sasikumar Adobe Employee

                                  When you start fdb, pass the command line option -unit.

                                   

                                  That is /sdks/4.5/bin/fdb -unit

                                  • 14. Re: ANT Debug
                                    Fredrick Backer Level 1

                                    ah. so easy and beutiful.

                                     

                                    So. Now I need to figure out to start the fdb with -unit run myfile.swf from ANT instead from my debug.sh file so that I can start different files.

                                     

                                    Thanks for the help, Will post final solution when I get the last ANT shell script to work.

                                    • 15. Re: ANT Debug
                                      Mike Britton Level 1

                                      Does this method actually activate the Eclipse-based Flash debugging environment for ANT and allow for breakpoints, variable inspection, etc?  I'm looking for a solution to do this.

                                      • 16. Re: ANT Debug
                                        Anirudh Sasikumar Adobe Employee

                                        No, this method relies on the command line debugger fdb. Eclipse does not come into play here.

                                         

                                        -Anirudh