Debugging code in Delphi XE

I have been using Delphi dev for a long time, and in the past I used a third-party development logging and debugging tool (called Smart Inspect), however now that I upgraded to Delphi XE, I want to try and use the IDE for debugging.

My question is, given a feature like

procedure MyFunction;
var
    str : string;
begin
    str := 'Foo';
    //Debug, show value of str?
    str := AnotherFunction(str);
    //Debug, show value of str?
end;

how can I debug and get the str value without doing stupid things like ShowMessage (str);

If there is a video somewhere (or an article), then I am more than happy to read.

Is there any way to see / display the value of variables.

+3
source share
6 answers

, Delphi XE CodeSite, , .

, , . " " "" IDE. , Watches , .

- , ( , ), Inspect (Alt-F5). , Evaluate/Modify (Ctrl-F7) . , Inspect, .

, .

+7

IDE, :

  • -
  • breakpointr " ..."
  • "", .
  • ""
  • " " " "

. "". ( "" )/hilight ( "" ) , .

+8

1) OutputDebugString

2) CodeSite Express. CodeRage 5 CodeSite

+5

.

( , da-soft) , , , , "" ( , , "" ). , , . , , , .

Delphi XE CodeSite, , . Code Site , , . , .

OutputDebugString (PChar (s)) . , , , .

, (.. 500 ). - , , , , .

Log 4 Delphi.

+1

I prefer the debugger tips. After hacking to the debugger, move the mouse pointer to "str" ​​anywhere in your code and you will see its current value. You can also select some instructions with the mouse and evaluate it. For example, select "AnotherFunction (str)" and hover over it.

0
source

Nothing wrong with the answers from others, but I just wanted to add these useful features.

procedure DebugString ( const s : string ) ; overload ;
begin
  {$IFDEF DEBUG}
  OutputDebugString ( PChar ( s ) ) ;
  {$ENDIF}
end ;

procedure DebugString ( const s : string ; args : array of const ) ; overload ;
begin
  {$IFDEF DEBUG}
  OutputDebugString ( PChar ( Format ( s , args ) ) ) ;
  {$ENDIF}
end ;
0
source

Source: https://habr.com/ru/post/1779457/


All Articles