[Lazarus] Another IDE interface question

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Another IDE interface question

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


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Another IDE interface question

Darius Blaszyk

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?
> 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


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Another IDE interface question

Mattias Gaertner
On Thu, 3 Feb 2011 18:49:56 +0100
Darius Blaszyk <[hidden email]> 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;



> > 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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Another IDE interface question

Darius Blaszyk

On Feb 3, 2011, at 7:43 PM, Mattias Gaertner wrote:

> On Thu, 3 Feb 2011 18:49:56 +0100
> Darius Blaszyk <[hidden email]> 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.

>
>
>>> 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
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Another IDE interface question

Mattias Gaertner
On Thu, 3 Feb 2011 19:52:46 +0100
Darius Blaszyk <[hidden email]> wrote:

> [...]
> >>> 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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Another IDE interface question

Darius Blaszyk
> 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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Another IDE interface question

Darius Blaszyk
In reply to this post by Mattias Gaertner
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 

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Another IDE interface question

Mattias Gaertner

 


Darius Blaszyk <[hidden email]> 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.

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

 


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Another IDE interface question

Darius Blaszyk

On Feb 5, 2011, at 4:02 PM, Mattias Gaertner wrote:

 


Darius Blaszyk <[hidden email]> 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.


    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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Another IDE interface question

Mattias Gaertner
On Sat, 5 Feb 2011 18:37:04 +0100
Darius Blaszyk <[hidden email]> wrote:

>[...]
> > 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

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus