Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-02

Another IDE interface question

10 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Darius Blaszyk
For the fpprofiler package I would like to know/do the following;

1. get all the -Fu and -Fi folders so the package can search them and allow the user to include/exclude them from profiling, which method to use in LazIDEIntf?
2. replace the FPC executable with the profiling frontend executable. currently I do:

//insert profiling code using TProcess
//build project using : LazarusIDE.DoBuildProject(crCompile, []);
//remove profiling code using TProcess
//execute project if LazarusIDE.ActiveProject.ExecutableType = petProgram

however, I'm not sure if it could be done better

TIA, Darius

Reply by email

Darius Blaszyk
to Darius Blaszyk
Darius Blaszyk wrote 11 lines
For the fpprofiler package I would like to know/do the following; 1. get all the -Fu and -Fi folders so the package can search them and allow the user to include/exclude them from profiling, which method to use in LazIDEIntf? 2. replace the FPC executable with the profiling frontend executable. currently I do: //insert profiling code using TProcess //build project using : LazarusIDE.DoBuildProject(crCompile, []); //remove profiling code using TProcess //execute project if LazarusIDE.ActiveProject.ExecutableType = petProgram however, I'm not sure if it could be done better

Ideally I would replace the FPC executable by FPP and then execute LazarusIDE.DoRunProject (??) . This way I would not have to play with TProcess to insert and remove profiling code and execute the application.

Darius

Reply by email

Mattias Gaertner
to Darius Blaszyk
Show quoted text 6 lines
On Feb 3, 2011, at 6:45 PM, Darius Blaszyk wrote: > For the fpprofiler package I would like to know/do the following; > > 1. get all the -Fu and -Fi folders so the package can search them and allow the user to include/exclude them from profiling, which method to use in LazIDEIntf?

I added some info:

http://wiki.lazarus.freepascal.org/Extending_the_IDE#Getting_the_search_paths_for_units_and_include_filesuses
CodeToolManager;
Show quoted text 10 lines
> 2. replace the FPC executable with the profiling frontend executable. currently I do: > > //insert profiling code using TProcess > //build project using : LazarusIDE.DoBuildProject(crCompile, []); > //remove profiling code using TProcess > //execute project if LazarusIDE.ActiveProject.ExecutableType = petProgram > > however, I'm not sure if it could be done better Ideally I would replace the FPC executable by FPP and then execute LazarusIDE.DoRunProject (??) . This way I would not have to play with TProcess to insert and remove profiling code and execute the application.

Can you explain this inserting/removing of profiling code?

Mattias

Reply by email

Darius Blaszyk
to Mattias Gaertner
Mattias Gaertner wrote 14 lines
On Thu, 3 Feb 2011 18:49:56 +0100 Darius Blaszyk wrote: > > On Feb 3, 2011, at 6:45 PM, Darius Blaszyk wrote: > >> For the fpprofiler package I would like to know/do the following; >> >> 1. get all the -Fu and -Fi folders so the package can search them and allow the user to include/exclude them from profiling, which method to use in LazIDEIntf? I added some info: http://wiki.lazarus.freepascal.org/Extending_the_IDE#Getting_the_search_paths_for_units_and_include_filesuses CodeToolManager;

Thank you for that.

Show quoted text 14 lines
>> 2. replace the FPC executable with the profiling frontend executable. currently I do: >> >> //insert profiling code using TProcess >> //build project using : LazarusIDE.DoBuildProject(crCompile, []); >> //remove profiling code using TProcess >> //execute project if LazarusIDE.ActiveProject.ExecutableType = petProgram >> >> however, I'm not sure if it could be done better > > Ideally I would replace the FPC executable by FPP and then execute LazarusIDE.DoRunProject (??) . This way I would not have to play with TProcess to insert and remove profiling code and execute the application. Can you explain this inserting/removing of profiling code?

Sure. In short:

I have written a simple front end for FPC called FPP. What it does is it searches all -Fu paths and inserts profiling code on each method it finds (using a modified version of fcl-passrc). Then it strips any FPP command line switches and passes the remaining switches directly to FPC. After compilation it strips the profiling code by restoring the backed up files.

see also: http://wiki.lazarus.freepascal.org/fpprofiler

Regards, Darius

Reply by email

Mattias Gaertner
to Darius Blaszyk
Show quoted text 18 lines
[...] >>> 2. replace the FPC executable with the profiling frontend executable. currently I do: >>> >>> //insert profiling code using TProcess >>> //build project using : LazarusIDE.DoBuildProject(crCompile, []); >>> //remove profiling code using TProcess >>> //execute project if LazarusIDE.ActiveProject.ExecutableType = petProgram >>> >>> however, I'm not sure if it could be done better >> >> Ideally I would replace the FPC executable by FPP and then execute LazarusIDE.DoRunProject (??) . This way I would not have to play with TProcess to insert and remove profiling code and execute the application. > > Can you explain this inserting/removing of profiling code? Sure. In short: I have written a simple front end for FPC called FPP. What it does is it searches all -Fu paths and inserts profiling code on each method it finds (using a modified version of fcl-passrc). Then it strips any FPP command line switches and passes the remaining switches directly to FPC. After compilation it strips the profiling code by restoring the backed up files. see also: http://wiki.lazarus.freepascal.org/fpprofiler

Ideally the procedure modifications can be done by FPC via a compiler switch, similar to the -pg switch.

Mattias

Reply by email

Unknown author
to Mattias Gaertner
Ideally the procedure modifications can be done by FPC via a compiler switch, similar to the -pg switch.

I'm not so sure. The current apprach uses instrumentation which by design has an impact on performance. With the current approach (separate profiling app) you can choose to instrument only a part of your code or even a couple of methods only (planned feature). A sampling profiler is much more appropriate for inclusion in the compiler.

Regards, Darius

Reply by email

Darius Blaszyk
to Mattias Gaertner: On Thu, 3 Feb 2011 18:49:56 +0100 I added some info:…
Show quoted text 6 lines
>> 1. get all the -Fu and -Fi folders so the package can search them and allow the user to include/exclude them from profiling, which method to use in LazIDEIntf? I added some info: http://wiki.lazarus.freepascal.org/Extending_the_IDE#Getting_the_search_paths_for_units_and_include_filesuses CodeToolManager;
Again a couple of questions regarding the IDE interface;

1. Is it possible to (temporarily) suppress the check if a file on disk has changed?
2. I would like to add a unit search path to the project and later be able to remove it again. Is this possible?

Regards, Darius
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110205/8fc08d0e/attachment.html>

Reply by email

Mattias Gaertner
to Darius Blaszyk

?

Darius Blaszyk hat am 5. Februar 2011 um 14:55
geschrieben:

Show quoted text 8 lines
> > > > > > > 1. get all the -Fu and -Fi folders so the package can search them and > > > allow the user to include/exclude them from profiling, which method to > > > use in LazIDEIntf?
Show quoted text 10 lines
> I added some info: > > http://wiki.lazarus.freepascal.org/Extending_the_IDE#Getting_the_search_paths_for_units_and_include_filesuses > CodeToolManager; > Again a couple of questions regarding the IDE interface; 1. Is it possible to (temporarily) suppress the check if a file on disk has changed?

?
No.?
I could add this, but maybe there are better ways than changing the source back and forth on disk.
Basically you need a preprocessor for FPC.
The first step is to extend FPC to not load files directly from disk. I tried some months ago and it was amazingly simple.
It is quite simple to build your own custom compiler and it uses a central place to load source files. With a simple patch the central loading can be extended for an overload. This costs no performance and has very low maintenance cost for the FPC team, so there is a good chance the patch will be applied. At that time DoDi was working on the compiler, so I waited for the dust to settle and then I forgot to provide the patch. The patch is on another computer. I can search for it next week.
A custom compiler can then add the file hook to feed fpc with preprocessed source files, for example your fpfprofile code.
Of course eventually it would be nice if FPC could use an optional preprocessor without the need to compile your own compiler.
?
Another solution is to implement a ramdisk. That would work with any existing compilers, but requires one implementation per OS and can be tricky because of access rights.
?
?
?

?? ?if FileExistsUTF8(Filename) then
?? ? ?LazarusIDE.DoRevertEditorFile(Filename)
?? ?else
?? ? ?LazarusIDE.DoCloseEditorFile(Filename,[cfQuiet]);
2. I would like to add a unit search path to the project and later be able to remove it again. Is this possible?

?
Yes.?
LazarusIDE.ActiveProject.LazCompilerOptions.OtherUnitFiles ?
But the handling of the modified flags can be tricky. ?
?
Mattias
?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110205/1a9b882b/attachment.html>

Reply by email

Darius Blaszyk
to Mattias Gaertner
Mattias Gaertner wrote 20 lines
Darius Blaszyk hat am 5. Februar 2011 um 14:55 geschrieben: >>>> 1. get all the -Fu and -Fi folders so the package can search them and allow the user to include/exclude them from profiling, which method to use in LazIDEIntf? >> >> I added some info: >> >> http://wiki.lazarus.freepascal.org/Extending_the_IDE#Getting_the_search_paths_for_units_and_include_filesuses >> CodeToolManager; > > Again a couple of questions regarding the IDE interface; > 1. Is it possible to (temporarily) suppress the check if a file on disk has changed? No. I could add this, but maybe there are better ways than changing the source back and forth on disk. Basically you need a preprocessor for FPC. The first step is to extend FPC to not load files directly from disk. I tried some months ago and it was amazingly simple. It is quite simple to build your own custom compiler and it uses a central place to load source files. With a simple patch the central loading can be extended for an overload. This costs no performance and has very low maintenance cost for the FPC team, so there is a good chance the patch will be applied. At that time DoDi was working on the compiler, so I waited for the dust to settle and then I forgot to provide the patch. The patch is on another computer. I can search for it next week.

Sounds very promising, I would welcome your sources to see if I can use this in fpprofiler.

A custom compiler can then add the file hook to feed fpc with preprocessed source files, for example your fpfprofile code.

Or even read the files from a stream instead, so the profiling code can be inserted on the fly?

Of course eventually it would be nice if FPC could use an optional preprocessor without the need to compile your own compiler.

I'm for that, sure. But I would also like to be able to use a profiler without the need to have to compile a new compiler with different pre-processor. Quite some users might find this difficult or even scary.

Another solution is to implement a ramdisk. That would work with any existing compilers, but requires one implementation per OS and can be tricky because of access rights.

It sounds to difficult to me. Not my prefference, in that case I would rather stay with disabling the check in Lazarus for changed files.

Show quoted text 8 lines
if FileExistsUTF8(Filename) then LazarusIDE.DoRevertEditorFile(Filename) else LazarusIDE.DoCloseEditorFile(Filename,[cfQuiet]); > 2. I would like to add a unit search path to the project and later be able to remove it again. Is this possible? Yes. LazarusIDE.ActiveProject.LazCompilerOptions.OtherUnitFiles But the handling of the modified flags can be tricky.

Thanks will examine how this works.

Regards, Darius
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110205/7f740117/attachment.html>

Reply by email

Mattias Gaertner
to Darius Blaszyk
Show quoted text 5 lines
[...] > Basically you need a preprocessor for FPC. > The first step is to extend FPC to not load files directly from disk. I tried some months ago and it was amazingly simple. > It is quite simple to build your own custom compiler and it uses a central place to load source files. With a simple patch the central loading can be extended for an overload. This costs no performance and has very low maintenance cost for the FPC team, so there is a good chance the patch will be applied. At that time DoDi was working on the compiler, so I waited for the dust to settle and then I forgot to provide the patch. The patch is on another computer. I can search for it next week. Sounds very promising, I would welcome your sources to see if I can use this in fpprofiler.

http://bugs.freepascal.org/view.php?id=18740

Mattias

Reply by email