Forum > General

Show source code comments during runtime ?

(1/2) > >>

FrankBKK:
Is there a way to show source code comments (or certain code parts, defined by e.g. line# or procedure name)
during runtime of the compiled program ?

I can of course open the source code during runtime as text file, filter what I need and show it for example in a memo,
but can this be achieved without having access to the source code during runtime ?







Thaddy:
No. FPC is a compiled language.
BUT during debugging of course this is possible. The debugger synchronizes that, depending on settings.

MarkMLl:
You can, however, do something like


--- Code: ---WriteLn(stderr, 'Entering ' + {$I %CURRENTROUTINE%} + '(), ' + {$I %FILE% } + ' line ' + {$I %LINE% });

--- End code ---

i.e. instruct the compiler to insert certain information into a string.

MarkMLl

FrankBKK:
Thanks Mark, I will give it a try ...

MarkMLl:
Various languages which are interpreted or semi-interpreted (i.e. not fully-compiled, Thaddy's point) will allow you to recover ("reflect upon") the source and/or Abstract Syntax Tree without reference to the original source files; in some cases this may be manipulated. This does not include mainstream compilers.

The above is somewhat beginner-friendly. The remainder is not.

You will, in some cases, be able to get access to RTTI information, but this definitely does not include descriptive comments. You might also be able to use debugging information to cross-reference- to some extent- between a location in memory and a sourcecode line.

You will also be able to use an external debugger to generate a backtrace from the point at which a program dumps its state an exception etc.

MarkMLl

Navigation

[0] Message Index

[#] Next page

Go to full version