Autor Beitrag
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Mi 19.12.07 12:32 
Moin Forum,

kann man eigentlich den Namen einen laufenden Prozedur abfragen?

z.B.:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure MachIrgendwas;
var prozedurname :String;
begin
  prozedurname := ???
  Showmessage(prozedurname);
end;

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 19.12.07 12:40 
Moin!

user profile iconjjturbo hat folgendes geschrieben:
kann man eigentlich den Namen einen laufenden Prozedur abfragen?

Ja, z.B. so: :zwinker:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure MachIrgendwas;
  var
    prozedurname: String;
begin
  prozedurname := 'MachIrgendwas';
  Showmessage(prozedurname);
end;

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Mi 19.12.07 12:44 
:lol:

Na so war´s net gemeint :wink:

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10183
Erhaltene Danke: 1256

W10ent
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 19.12.07 13:38 
Moin!

Klar ;) also im Ernst: Die Prozedurnamen sind nur zur Entwurfszeit bekannt und gehen beim Compilieren verloren (werden durch Adressen ersetzt). :idea:

Deshalb ist der Vorschlag oben wohl die einfachste Möglichkeit. :nixweiss: ich gehe mal davon aus, dass man Programme üblicherweise ohne Debuginfos ausliefert; sofern dich das nicht stört, hast du ja im Folgenden genug alternativen... *g*

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.


Zuletzt bearbeitet von Narses am Do 20.12.07 00:04, insgesamt 2-mal bearbeitet
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mi 19.12.07 13:45 
Ja es ist möglich. Es ist sogar möglich, den ganzen Call-Stack zur Laufzeit auszulesen. Jedi sollte sowas zur Verfügung stellen. Damit es klappt, müssen Debugging-Informationen aber mit eincompiliert werden.

Fürs Debugging reicht es aber meistens aus, mit Assert zu arbeiten. Damit erhältst du Source-File und Zeilennummer der jeweiligen Stelle.
Martin1966
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1068

Win 2000, Win XP
Delphi 7, Delphi 2005
BeitragVerfasst: Mi 19.12.07 13:47 
Sinnvoll wäre es hier den Verwendungszweck zu kennen. Also jjturbo? ;-)

_________________
Ein Nutzer der Ecke ;-)
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Mi 19.12.07 13:55 
Ich entwickle gerade eine Komponente zur automatischen Steuerung von Rollenbahnen. Damit auf der SPS-Ebene für die Standardanwendungen so gut wie nichts mehr dafür programmiert werden muß, muß das Ding einigermassen "Intelligent" sein.
Bestimmte Änderungen an diversen Eingangssignalen rufen bestimmte Prozeduren auf. Um sicher zu stellen, daß alles richtig verkabelt ist, gibt es einen Inbetriebnahmemodus.
Da dachte ich mir: Einfach ein Showmessage mit dem Prozedurnamen und gut. Und da ich einigermassen schreibfaul bin, stellte sich mir die Frage ob so was geht :wink:

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mi 19.12.07 14:07 
Für schnelles Debugging reicht vielleicht das:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Assert(false); // Zeigt Datei/Zeilennummer an
end;

procedure MyAssert(const Message, Filename: string;
    LineNumber: Integer; ErrorAddr: Pointer);
begin
  ShowMessage('Datei: '+FileName+#13#10+
              'Zeile: '+IntToStr(LineNumber));
end;

initialization
  AssertErrorProc := MyAssert;
end.


Ansonsten wie gesagt, siehe JclDebug.pas, Stack-Trace, Call-Stack.
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Mi 19.12.07 14:09 
Hallo,

ja das geht.

Ist nur etwas aufwendig.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
  function GetEbp : dword;
  asm
    mov eax, ebp
  end;


Damit holen wir und mal den passenden Einsprungspunkt.

Der Datentyp sollte ein Array von Pointern sein.
Der zweite Pointer im Array sollte die passende Adresse sein.

Dann noch in TMethod casten und in MethodName() stecken.

Sollte das gewünschte Ergebnis sein.

Alternativ wäre auch MadExcept von MadShi eine Möglichkeit (www.madshi.net).

StackTraces wären sicher interessanter als MethodName.

r u

René

PS: Linker-Adress-Map-File anhängen ist auch keine schlechte Idee.

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Mi 19.12.07 20:16 
hmm... :?
Hat jemand ein Beispiel mit Erklärung dafür?

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
hazard999
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 162

Win XP SP2
VS 2010 Ultimate, CC.Net, Unity, Pex, Moles, DevExpress eXpress App
BeitragVerfasst: Do 20.12.07 09:09 
Hallo nochmal,

das einfachste ist sicher wenn du dir MadExcept besorgst.

uses madStackTrace;

showmessage(StackTrace(true,false,false,nil,nil,false,false));

Erzeugt einen sehr schönen Output (samt Zeilennummer wenn das Map-File in der binary enthalten ist).

Und 99$ für single developer oder 399 für site license ist ein Spotpreis.

Die 399$ hatten wir innerhalb von einem Monat wieder herrinnen.

r u

René

_________________
MOV EAX, Result;MOV BYTE PTR [EAX], $B9;MOV ECX, M.Data;MOV DWORD PTR [EAX+$1], ECX;MOV BYTE PTR [EAX+$5], $5A;MOV BYTE PTR [EAX+$6], $51;MOV BYTE PTR [EAX+$7], $52;MOV BYTE PTR [EAX+$8], $B9;MOV ECX, M.Code;MOV DWORD PTR [EAX+$9], ECX
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Do 20.12.07 10:05 
user profile iconhazard999 hat folgendes geschrieben:
Hallo nochmal,

das einfachste ist sicher wenn du dir MadExcept besorgst.

Naja, ich denke mal, es ist vielleicht noch einfacher, wenn er die Jedi-Units holt. Die sind kostenlos und die Sources sind mit dabei.
sourceforge.net/projects/jvcl