Recent

Author Topic: How to check if function or procedure is actually doing something  (Read 1288 times)

vask0to

  • Newbie
  • Posts: 1
Lets say I have this procedure which contains only comment and no executable code in its body.
Code: Pascal  [Select][+][-]
  1.    procedure Procedure1
  2.    begin
  3.    //comment
  4.    end;
Is there a way to call this function and verify wheter it does something or doesn't actually do anything?
And also the same for a function.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: How to check if function or procedure is actually doing something
« Reply #1 on: July 06, 2020, 02:55:52 pm »
You can examine the assembler output.
You will find that depending on optimization settings it does nothing because the compiler can remove such code.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: How to check if function or procedure is actually doing something
« Reply #2 on: July 06, 2020, 03:32:47 pm »
There's
  Refactoring -> Empty methods ...
but the methods must be really empty, i.e. no comment.
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: How to check if function or procedure is actually doing something
« Reply #3 on: July 06, 2020, 04:43:42 pm »
I like using BEEPS...  :D

Put a BEEP in there.. and it will sound your speakers if it gets executed
The only true wisdom is knowing you know nothing

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: How to check if function or procedure is actually doing something
« Reply #4 on: July 07, 2020, 05:18:44 am »
Beware the warning in the FPC documentation: "Beep contains no implementation to actually produce a beep, since there is no way to implement beep in a meaningful way for all possible implementations."

I discovered that, for example, in macOS and FreeBSD it does nothing.

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: How to check if function or procedure is actually doing something
« Reply #5 on: July 07, 2020, 03:31:04 pm »
Use a break point then. If it jumps to that block it will stop there and prompt u.
The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: How to check if function or procedure is actually doing something
« Reply #6 on: July 07, 2020, 03:34:20 pm »
There's
  Refactoring -> Empty methods ...
but the methods must be really empty, i.e. no comment.
No. depending on optimization no code is no code to the compiler. It is just the Lazarus ide that keeps the comment in place for the project, but not for the compiler....
There is a big difference. You can check that by examining the assembler output.
« Last Edit: July 07, 2020, 03:37:13 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018