Autor Beitrag
ShadowThief
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278



BeitragVerfasst: Mo 28.07.03 01:57 
hallo,

ich bin gerade dabei einen lemmings-clone zu schreiben und bin dann auf ein für mich sehr komisches problem gestoßen. normalerweise hätte ich hier den code posten können, aber ich zeig euch das lieber als bild, sonst glaub ihr mirs evtl. nicht:

user defined image

ich bin gerade am debuggen und hab meine maus über dem h bei h = 2, nur die maus kann man bei windows-screenshots nicht sehen. das programm ist gerade in der rot markierten zeile. d. h. :

obwohl h = 0 ist, macht er den break. (btw: die leerzeile hab ich für den screenshot absichtlich reingemacht, sonst hätte man das break nicht gesehen)

ja.
shadow.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 28.07.03 10:16 
Hallo!

Die Variable H ist wahrscheinlich deshalb 0 weil nach der
ausblenden Delphi-Quelltext
1:
If h = 2 Then					

Zeile H nicht mehr benötigt wird. Setz den Breakpoint mal auf die Zeile
ausblenden Delphi-Quelltext
1:
If h = 2 Then					

und werte dann die Variable H aus.

Gruß
Tino
ShadowThief Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278



BeitragVerfasst: Mo 28.07.03 10:24 
hab ich schon probiert, ich hab keine breakpoint auf das if gemacht,
trotzdem.

ich hab auch schon meinen rechner neu gestartet, das projekt neu
angelegt. nur delphi hab ich noch nicht neu installiert, aber da hab
ich auch keinen bock drauf.
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mo 28.07.03 11:13 
ShadowThief hat folgendes geschrieben:
das programm ist gerade in der rot markierten zeile.

Auf ein Break in einer If-Anweidung kann man gar keinen Breakpoint setzen. Zumindest nicht bei Delphi 6.

Zitat:
obwohl h = 0 ist, macht er den break.

Das kann auch daran liegen, dass der Code-Optimierer die Variable h vielleicht in ein CPU Register gestellt hat.

_________________
Ist Zeit wirklich Geld?
ShadowThief Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278



BeitragVerfasst: Mo 28.07.03 11:33 
na gut, von registern versteh ich nix.
ich weiss nur, dass er den break macht, obwohl er ihn
nicht machen dürfte.

stimmt, bei d6 kann man da keinen break setzen, aber bei d7
gehts.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Mo 28.07.03 12:37 
ShadowThief hat folgendes geschrieben:
hab ich schon probiert, ich hab keine breakpoint auf das if gemacht, trotzdem.

Wie jetzt? Hast du jetzt einen Breakpoint auf die If-Then Zeile gesetzt, gestartet und anschl. die Variable H ausgewertet?

Gruß
Tino
ShadowThief Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278



BeitragVerfasst: Mo 28.07.03 13:11 
ja hab ich
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Mo 28.07.03 13:20 
Lass dir mal mit
ausblenden Delphi-Quelltext
1:
Showmessage(IntToStr(h));					

Die Variable h noch vor der if-Abfrage ausgeben.
Dann umgehst du zum Beispiel das Problem, das Andy angesprochen hat und weißt, welchen Wert h wirklich hat und ob er break wirklich ausführen sollte, oder es doch ein Fehler ist.

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert


Zuletzt bearbeitet von tommie-lie am Mo 28.07.03 13:36, insgesamt 1-mal bearbeitet
ShadowThief Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278



BeitragVerfasst: Mo 28.07.03 13:23 
ich hab gerade was lustiges bemerkt, keine ahnung warum ich das vorher nicht gesehen habe:

h ist ja an der kritischen stelle 0. dann kommt ein if, nämlich ob h = 2 ist, was es ja nicht ist, weil es ja 0 ist, dann geh ich im debugger einen schritt weiter und bin dann beim break, was ja nicht sein dürfte. geh ich jetzt noch einen schritt weiter, läuft das programm normal weiter. das break wirds sozusagen ignoriert, obwohl dieser lustige grüne pfeil links eindeutig auf dem break war. komisch. naja, auch egal. der code funktioniert, nur der debugger spinnt mal wieder n weng.

puuh.
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 28.07.03 18:30 
Hast du Teile des Codes per Copy&Paste eingefügt? Da kann es dann nämlich vorkommen, dass beim kopieren ein Teil des Zeilenumbruchs verlorengegangen ist (ein Zeilenumbruch wird ja durch 2 Zeichen dargestellt). Der Editor bricht die Zeilen zwar richtig um, aber der Debugger ist dann immer in der falschen Zeile... das Problem lässt sich recht einfach beheben - einfach die Eingabeaufforderung starten, die pas-Datei im DOS-Editor öffnen, einmal speichern (der Editor korrigiert dann die Zeilenumbrüche) und das wars auch schon..!

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
ShadowThief Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 278



BeitragVerfasst: Fr 08.08.03 14:59 
ich hab das mal probiert, aber hat nix geholfen.
is ja jetzt auch egal, weil der code funktioniert ja, das is das wichtigste.
vielen danke für die hilfe.

shadow.

ps: ich war im urlaub, deswegen hab ich so lange nicht geantwortet.
Raptor
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 48

WIN 98 / WIN XP prof.
D 5 St. / D 3 prof.
BeitragVerfasst: Sa 09.08.03 13:19 
Kann es sein das
ausblenden Delphi-Quelltext
1:
2:
3:
if h=2 then 

Break

für den Compiler das gleiche ist wie
[code]
if h = 2 then Break;
[/delphi]
dann würde er doch auch bei h = 0 bei einen Breakpoint in dieser Zeile stehen bleiben, oder? Aber vieleicht is mir auch nur zu warm, und ich kann nicht klar denken :?:

_________________
Semper aliquid haeret RAPTOR
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Sa 09.08.03 18:04 
Das ist für den Compiler das gleiche. Dieser entfernt nämlich sämtliche Leerzeichen und Zeilenumbrüche, wenn er seine Baumstruktur aufbaut.

_________________
Ist Zeit wirklich Geld?