Announcement

Collapse
No announcement yet.

DEBUG: How to debug?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • DEBUG: How to debug?

    I'm interested in understanding how the game works and maybe will someday also help to fix some errors.

    I've downloaded the source and compiled and linked the exe for Win32 Debug with VS6.0.

    Had no problems to debug the program startup. But when it comes to the execution of some specific stuff in the yyparse function of ldl.tab.c file, the program takes control over the debugger (as far as i guess) and I can't debug anymore what's happening.

    Can someone give me some hints, what I have to do, so I can debug throug the C++ source code during a game.

    Is it only possible with a remote debug or exist other easier ways?

    Played also around with the starting parameters "runinbackground" and "nonexclusive" but this did not help.
    Ludwig

  • #2
    When you run the debug version of the game, Win32 Debug, it will create a number of log files, in the logs folder and in the game folder itself. From these you can track down call stack and events pretty well, as well as see what the memory leaks are. They're probably the most useful thing when debugging CtP2.
    Solver, WePlayCiv Co-Administrator
    Contact: solver-at-weplayciv-dot-com
    I can kill you whenever I please... but not today. - The Cigarette Smoking Man

    Comment


    • #3
      FWIW, I have "nointromovie nonexclusive" as program arguments for debugging.

      The first one should not really matter - apart from saving you some time at start-up.

      Without the second one, I used to lose control at the end of ui_Initialize in civ3_main.cpp. With it, 2 cursors (the usual Windows one and the CTP2 hand) will appear, and I am able to switch between the application and the debugger. However, the debugger is a bit slow when switching. It takes about 1 or 2 seconds to get responsive. But apart from that, it works fine.
      If your video card supports it, and you have a second monitor, you may want to try out the "multimon" option instead. I can't use it, because my video card does not support more than 1 monitor.

      When stepping through one of the files that have been generated by Lex and Yacc, you may get confused somewhat. Guided by the generated #line-statements, the debugger will sometimes switch to the input file (ldl.y in your case). Unless you really want to debug these specific files, you may avoid this by simply not stepping into ldlparse/yyparse when debugging.

      Comment


      • #4
        Thanks that you took the time to answer my question.

        Meanwhile I also added the parameter "notimeslice" and the debugging now works nearly perfect, also without a second monitor.

        EDIT:
        And it's also a good idea to deactivate virus scanning on the directories the c++ compiler writes to.
        Last edited by Lui2; June 13, 2004, 04:26.
        Ludwig

        Comment


        • #5
          I have successfully compiled and built a _dbg.exe with the 2004.06.05.CTP2.All.zip code compilation.

          Should I be able to execute the _dbg.exe immediately after the build completes? The way I got it to work was to copy the _dbg.exe and a .dll (anet2?) to the directory where my playtest game is installed. Then I changed the project/debug path setting to the game dir path from the code dir path. Now I can start the game by pressing F5 in vc++. I have played about 50 turns this way. With 23 AI civs, I saw the "NO_CONTACT_DECLARE_WAR" assertion failure on about 35 of the turns.

          I added the "nointromovie nonexclusive notimeslice" program arguments, and I can sometimes see the two cursors. But I can never use either one independantly, and most attempts to force vc++ to the top hang both programs. If an assertion pops up, I can click retry and go to vc++ or click ignore and go back to the game. But otherwise, once the game starts going I'm locked into playing unless an assertion pops up. Is there a way to toggle between the game and the debugger with a keypress or something?

          I was able to load a saved game started with the playtest build from early May (the last one posted in .zip format) Once it loaded, I noticed the movement delay bug mentioned in the playtest thread, this behavior did not exist when I originally saved the playtest game.

          When I ended the first turn, it took about 50 minutes for it to be my turn again (about 30 civs). During that time at least half of the AI civs threw an assertion failure at gs/slic/sliccmd.cpp line 414 where it seems a certain struct sliccmdExpValue (v) has a ->type but not a ->sym

          Code:
          	Assert(v->type == EXP_VAL_SYM || v->type == EXP_VAL_TEMP_SYM);
          	SlicSymbolData *sym = (SlicSymbolData *)v->sym;
          
          	Assert(sym); // line 414
          	if(!sym) {
          		strcpy(sliccmd_output, "");
          		return;
          	}
          I also saw a couple of "NO_REFUEL_BASE" (not exact) assertion failures before AI fighters dropped out of the skies. (couldn't see them, heard them crash)

          When I ended the next turn, both programs hung during the second or third AI's turn. But since I had walked away, the hang might be because my computer went into sleep mode while I was away. (I had to completely reboot through "ctrl-alt-delete shutdown" to get back)

          What's the best way to configure my system to assist the project? I get lost in the code pretty easily, but I can accurately report what happens when things act up. I plan to update as soon as the next .all code changes pack is issued, and then to stay up to date as each new change is posted. Any other suggestions?

          Comment


          • #6
            I also use the parameter "runinbackground" and can easily switch between the VC++ and the ctp2 application with CTRL-TAB. But I'm not sure, if that is the reason for your problems.

            Sometimes the screen is a bit mixed but by repeating CTRL-TAB i can always get it right.

            Check that you have a clean installation without any mods and than add the changed source code and data files.

            And take care about virus checkers. They slowed my start of debugging with a factor of 100 or so. Now the game starts in debugging mode nearly as fast as the normal game.

            The "NO_CONTACT_DECLARE_WAR" assertion will be called when a slave driver is making a raid for slaves and the civilization of the attacked city had no contact before with the owner of the slave driver. I have this on my lists to change to suppress this assertion warning.
            Ludwig

            Comment


            • #7
              I wouldn't run a game in debug mode with 32 civs or 28 civs, with so many civs in the game the game is slow already slow even in a non debug invironment. With all the extra stuff that is done in the debug version like logging and writing events to a file you can expect to see the game much slower then in a non debug invironment, the slowdown is even notable with 10 players but at least manageable.

              -Martin
              Civ2 military advisor: "No complaints, Sir!"

              Comment


              • #8
                Getting AI Logs

                Hello,

                Question about Logs :
                I can get the diplomacy logs, main logs civ3logsxxx.txt, but I didn't manage to get the AI logs. could anyone help me ?

                I try several Playtest commands
                (god to see the entire map,
                armyText to see the army goal on the screen,
                ...)

                but the command ailog debug_level team_idx doesn't seems to work :

                I saw in source code 4 levels of log (OFF -> Detailled)
                but the command ailog in C3Cmdlines seems to be empty.

                the command aidebug goal_type player didn't succes as well.

                Comment


                • #9
                  I think they would be written into the civ3logsxxx.txt files the was a line in the source, that has to be changed to enable all logs or a selection of the logs. But I can't recall were to find them. Peter posted a bout them.

                  -Martin
                  Civ2 military advisor: "No complaints, Sir!"

                  Comment

                  Working...
                  X