2010-11-27 19 views
1

Je continue d'obtenir ces numéros de ligne pour les erreurs dans les fichiers cpp bibliothèques externes, je n'ai aucun moyen de savoir quelle partie de mon code fait cette erreur. Parfois, il montre même morceau de code d'assemblage où il s'est écrasé ...Comment déboguer dans Visual Studio 2008

Comment puis-je obtenir la ligne où mon propre code a provoqué cette erreur? Ou au moins une idée de quelle partie de mon code fait ce crash ...

Parfois, il ne dit même pas n'importe quel numéro de ligne, je ne comprends pas vraiment comment fonctionne ce mode de débogage. J'ai utilisé le vérificateur d'application, et il donne parfois des numéros de ligne. On dirait qu'il me dit ces choses au hasard ... comment puis-je résoudre ça?

C'est ce que je reçois:

First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dd4c.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dc50.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dc50.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dd48.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012d9a8.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dc6c.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dcd0.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dabc.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dabc.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dabc.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db5c.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dabc.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dc30.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db48.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db64.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db5c.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db48.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012db04.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dabc.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012da04.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dc30.. 
First-chance exception at 0x7c812aeb in test.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0012dcd0.. 

Répondre

2

Utilisez des points d'arrêt sur la ligne de code où vous voulez l'exécution du programme « pause ». De cette façon, vous serez en mesure de voir l'état du programme (les valeurs des variables, etc, etc).

Ici vous avez une série de tutoriels sur la façon de tout configurer, pour obtenir le débogage.

+0

Ah ... je commence à comprendre, mais maintenant je me sens mal à ce sujet, il se bloque à 'glewInit();', comment je suis supposé résoudre ce problème? – Newbie

+0

effectivement, son écrasement à chaque ligne de code possible ... sauf maintenant quand j'ai désactivé le vérificateur d'application o.O – Newbie

+0

en fait, maintenant il ne tombe même pas sur le glewInit() plus maintenant ... que dois-je faire maintenant? Je n'ai pas changé de code, mais j'ai parfois des plantages aléatoires, on dirait. – Newbie

4

Le débogueur MSVC est extrêmement puissant. Le prix que vous payez est aussi complexe.

Vous pouvez indiquer au débogueur d'interrompre toute exception non gérée. Ceci est désactivé par défaut. Dans votre cas, vous voulez rompre avec les exceptions de première chance. Pour ce faire:

Allez à Debug> Exceptions ... Dans la boîte de dialogue qui apparaît, cochez les cases à côté de "Exceptions C++" et "Exceptions Win32".

Exécutez votre programme. Il devrait casser quand ces exceptions se produisent. Gardez à l'esprit que les exceptions de première chance sont largement utilisées dans MFC pour communiquer entre les composants. Ce ne sont pas des erreurs. Mais vous les verrez dans la fenêtre de sortie. S'ils ne sont pas gérés, c'est alors que cela devient un problème que vous devez résoudre.