Answers.Body: <p>Did you set she compiler / linker flags correctly? (<code>/DEBUG</code> in the linker, <code>/Od</code> and <code>/Zi</code> in the compiler - which flags did you set?) Is the pdb-file located in the same directory as the executable? You can also manually load the pdb after breaking in your code and see, if symbols appear. If not, look at the flags.</p>
  
  <p>To avoid the "attach to process", you can also put a</p>
  
  <blockquote>
    <p>__debugbreak();</p>
  </blockquote>
  
  <p>in your code. This also avoids any mishaps with choosing the wrong process to attach to.
  I would probably put the break somewhere where the "uci" command is handled.</p>
  
  <p>But both methods to attach the debugger are valid and should normally work.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-10T13:31:22.010Z
Answers.Text: Well I used visual studio 2019's "console app" project template, which indeed (for debug configuration) sets a `/DEBUG` for the linker, an `/Od` for the optimization and a `/Zl` (and not a `/Zi`, see the difference here https://docs.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format?view=vs-2019, it should be fine) for the pdb generation, which should be fine. The .exe of the engine is compiled and placed in the same folder as its associated pdb file, so that there should not be a problem.
Answers.UserDisplayName: Olórin
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-10T09:47:16.387Z
Answers.LastActivityDate: 2020-01-10T09:47:16.387Z
Answers.UserDisplayName: Jens
Body: <p>I coded (with visual studio 2019 on windows 10) an ultra naive chess engine that complies with UCI engine interface rules. Before starting to develop it in more fancy ways, I want to make sure that I can debug my code via using my engine from a chess GUI. Hence I decided to debug it with <a href="http://www.playwitharena.de/" rel="nofollow noreferrer">Arena</a>.</p>
  
  <p>I tried the following two standard debugging methods :</p>
  
  <ul>
  <li><p>In the properties of the project used to compile my engine I put (the path to) arena.exe in the command to execute when the debug is launched, and then, when debug is triggered and arena opened, I load in Arena a new engine corresponding to my engine, I put breakpoints in my code but each has a "no symbols loaded".</p></li>
  <li><p>I launch Arena, I load a new engine in it, the engine being the compiled debug version of my engine, and then in visual studio I make an "attach to process" and add Arena as process to attach to. Then the breakpoints in my code in visual studio have also "no symbols loaded".</p></li>
  </ul>
  
  <p>Am I missing something or not?</p>
  
  <p>I am not sure if CSE is the most suitable place to post this question but I wanted to give it a try before maybe posting on <a href="https://gamedev.stackexchange.com/">gamedev.stackexchange.com</a>.</p>
  
  <p><strong>Precision 1.</strong> I have the same problem if I take StockFish's source code, compile it in a console project in Visual Studio 2019 and try to do as explained above.</p>
  
  <p><strong>Precision 2.</strong> I also finally posted on SE here <a href="https://stackoverflow.com/questions/59687256/debugging-a-console-chessengine-exe-used-in-another-application-a-chess-gui">https://stackoverflow.com/questions/59687256/debugging-a-console-chessengine-exe-used-in-another-application-a-chess-gui</a></p>
  
Tags: <programming><uci><arena><windows>
Title: Debugging my chess engine through the Arena GUI
ThreadText: # Debugging my chess engine through the Arena GUI
  
  (Asked by: username_0 on 2020-01-09)
  
  I coded (with visual studio 2019 on windows 10) an ultra naive chess engine that complies with UCI engine interface rules. Before starting to develop it in more fancy ways, I want to make sure that I can debug my code via using my engine from a chess GUI. Hence I decided to debug it with [Arena](http://www.playwitharena.de/).
  
  I tried the following two standard debugging methods :
  
  * In the properties of the project used to compile my engine I put (the path to) arena.exe in the command to execute when the debug is launched, and then, when debug is triggered and arena opened, I load in Arena a new engine corresponding to my engine, I put breakpoints in my code but each has a "no symbols loaded".
  * I launch Arena, I load a new engine in it, the engine being the compiled debug version of my engine, and then in visual studio I make an "attach to process" and add Arena as process to attach to. Then the breakpoints in my code in visual studio have also "no symbols loaded".
  
  Am I missing something or not?
  
  I am not sure if CSE is the most suitable place to post this question but I wanted to give it a try before maybe posting on [gamedev.stackexchange.com](https://gamedev.stackexchange.com/).
  
  **Precision 1.** I have the same problem if I take StockFish's source code, compile it in a console project in Visual Studio 2019 and try to do as explained above.
  
  **Precision 2.** I also finally posted on SE here <https://stackoverflow.com/questions/59687256/debugging-a-console-chessengine-exe-used-in-another-application-a-chess-gui>
  
  **Tags:** programming, uci, arena, windows
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-01-10. Score: 1
  
  Did you set she compiler / linker flags correctly? (`/DEBUG` in the linker, `/Od` and `/Zi` in the compiler - which flags did you set?) Is the pdb-file located in the same directory as the executable? You can also manually load the pdb after breaking in your code and see, if symbols appear. If not, look at the flags.
  
  To avoid the "attach to process", you can also put a
  
  > \_\_debugbreak();
  
  in your code. This also avoids any mishaps with choosing the wrong process to attach to.
  I would probably put the break somewhere where the "uci" command is handled.
  
  But both methods to attach the debugger are valid and should normally work.
  
  > **Comments:**
  > **username_0**: Well I used visual studio 2019's "console app" project template, which indeed (for debug configuration) sets a `/DEBUG` for the linker, an `/Od` for the optimization and a `/Zl` (and not a `/Zi`, see the difference here https://docs.microsoft.com/en-us/cpp/build/reference/z7-zi-zi-debug-information-format?view=vs-2019, it should be fine) for the pdb generation, which should be fine. The .exe of the engine is compiled and placed in the same folder as its associated pdb file, so that there should not be a problem.  
  
  ---
  
  