Differences
This shows you the differences between two versions of the page.
programming:visual-studio [2006/12/13 20:54] cyril |
programming:visual-studio [2013/09/19 16:41] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Visual Studio tips ====== | ||
- | ===== Useful features for debug ===== | ||
- | |||
- | You probably already know classical features such as step-by-step execution ('' | ||
- | |||
- | But there are also a lot of other very useful features for debugging. | ||
- | |||
- | ==== Navigation ==== | ||
- | |||
- | * '' | ||
- | * '' | ||
- | * '' | ||
- | |||
- | ==== Debugging a DLL ==== | ||
- | |||
- | You can debug a DLL (with step-by-step execution, breakpoints and all the usual stuff) when it is launched by any program. | ||
- | |||
- | In '' | ||
- | |||
- | Then, just put a breakpoint in your DLL source code, '' | ||
- | |||
- | Remark : the DLL that the executable use must be the same that the one generated by Visual Studio (you can't move or copy it). But it is simple to configure Visual Studio in order to generate the DLL in the path you want. | ||
- | |||
- | ==== Attaching the debugger to a running process ==== | ||
- | |||
- | If your program is used by another program and you want debug it in this context, you can. | ||
- | |||
- | With Visual Studio you can attach the debugger to a running process. Set '' | ||
- | |||
- | Then, just put a breakpoint in your DLL source code, launch your program in any way you want, and after attach the debugger with '' | ||
- | |||
- | ==== Memory errors ==== | ||
- | |||
- | In non-managed C++, Visual Studio uses special libraries in Debug mode, which add a lot of verifications when allocating or freeing memory, in order to detect some problems in your code. But unhappily it won't detect all errors, in particular access to non allocated memory areas. | ||
- | |||
- | There exist some tools which can do that, such as Purify for example, but I don't know any free tool for Windows (for Linux there is the excellent Valgrind). | ||
- | |||
- | The problem with these errors is that they are not deterministic, | ||
- | |||
- | An artisanal way to try to deal with that can be to allocate huge buffers of memory that you don't touch, but you compute checksums of theses buffers all along your code. If your code is wrong and write data outside allocated areas, it can modify these buffers and you will see it. Of course you're not sure at all it will detect your errors, but there is a chance. | ||
- | |||
- | There is a tool which automates this procedure with other stuff, called Memwatch, but this is still not foolproof. | ||
- | |||
- | |||
- | ===== Errors ===== | ||
- | ==== Ambiguous symbol ==== | ||
- | |||
- | When using threads ('' | ||
- | |||
- | Just try to move the ''# |