FPC and Profiling software

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

FPC and Profiling software

Graeme Geldenhuys-2
Hi,

Does anybody know of any profiling software I can use with FPC? I'm
mainly developing under Linux, but have a virtual Win2000 session as
well, so Windows or Linux software will do.

I'm trying to detect where bottlenecks occur in my code.

Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: FPC and Profiling software

Graeme Geldenhuys-2
Hi,

Doing some searching in the mailing list archives it seems I can use
'gprof' for profiling. Anybody got a tutorial or wiki page explaining
it's usage with FPC programs?

Graeme.



On 13/03/2008, Graeme Geldenhuys <[hidden email]> wrote:

> Hi,
>
>  Does anybody know of any profiling software I can use with FPC? I'm
>  mainly developing under Linux, but have a virtual Win2000 session as
>  well, so Windows or Linux software will do.
>
>  I'm trying to detect where bottlenecks occur in my code.
>
>  Regards,
>   - Graeme -
>
>
>  _______________________________________________
>  fpGUI - a cross-platform Free Pascal GUI toolkit
>  http://opensoft.homeip.net/fpgui/
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Firebird UDF

Codebue Fabio - P-Soft
This is my UDF source

library pudf;
  {$mode objfpc}{$H+}
uses
  Classes;

function pround(var valore: real; ndec: integer):real;export;
var
  i: integer;
  risultato: real;
  ndivisore: integer;
begin
  risultato:= valore;
  ndivisore:= 1;
  for i:= 1 to ndec do
  begin
    risultato:= risultato*10;
    ndivisore:= ndivisore*10;
  end;
  result:= round(risultato)/ndivisore;
end;

exports
  pround name 'pround';

begin
end.

but after insert into my fdb with instruction

DECLARE EXTERNAL FUNCTION pround
DOUBLE PRECISION, INTEGER
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'pround' MODULE_NAME 'pudf';

if I use it with an instruction like this

select round(123.1233, 2) as nrounded from rdb$database

I have back this error

Invalid token.
invalid request BLR at offset 59.
function PROUND is not defined.
module name or entrypoint could not be found.

do you have some idea regarding this error?

Codebue Fabio
.-----------------------------.
  _ \       __|       _||
  __/____|\__ \  _ \  _| _|
 _|       ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web  : www.p-soft.biz
EMail: [hidden email]  


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Firebird UDF

Michael Van Canneyt


On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote:

> This is my UDF source
>
> library pudf;
>   {$mode objfpc}{$H+}
> uses
>   Classes;
>
> function pround(var valore: real; ndec: integer):real;export;
> var
>   i: integer;
>   risultato: real;
>   ndivisore: integer;
> begin
>   risultato:= valore;
>   ndivisore:= 1;
>   for i:= 1 to ndec do
>   begin
>     risultato:= risultato*10;
>     ndivisore:= ndivisore*10;
>   end;
>   result:= round(risultato)/ndivisore;
> end;
>
> exports
>   pround name 'pround';
>
> begin
> end.
>
> but after insert into my fdb with instruction
>
> DECLARE EXTERNAL FUNCTION pround
> DOUBLE PRECISION, INTEGER
> RETURNS DOUBLE PRECISION BY VALUE
> ENTRY_POINT 'pround' MODULE_NAME 'pudf';
>
> if I use it with an instruction like this
>
> select round(123.1233, 2) as nrounded from rdb$database
>
> I have back this error
>
> Invalid token.
> invalid request BLR at offset 59.
> function PROUND is not defined.
> module name or entrypoint could not be found.
>
> do you have some idea regarding this error?

Where did you put the library, what is the library name ?

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: FPC and Profiling software

Jeff Pohlmeyer
In reply to this post by Graeme Geldenhuys-2
Graeme Geldenhuys wrote:

> I'm trying to detect where bottlenecks occur in my code.

On Linux, you can get some interesting information with something like this:

% valgrind --tool=callgrind  [YOUR_APP]  [YOUR_ARGS]
% callgrind_annotate --auto=yes --inclusive=yes > callgrind.log

And then have a look at "callgrind.log"

To use this, just be sure you do NOT compile your app with -pg !

More info at http://valgrind.org/

 - Jeff
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Firebird UDF

Crause, Christo (JC)
In reply to this post by Codebue Fabio - P-Soft
> From: "Codebue Fabio - P-Soft"
...
> function pround(var valore: real; ndec: integer):real;export;
...

> DECLARE EXTERNAL FUNCTION pround
> DOUBLE PRECISION, INTEGER
> RETURNS DOUBLE PRECISION BY VALUE
> ENTRY_POINT 'pround' MODULE_NAME 'pudf';
>
> if I use it with an instruction like this
>
> select round(123.1233, 2) as nrounded from rdb$database
>
> I have back this error
>
> Invalid token.
> invalid request BLR at offset 59.
> function PROUND is not defined.
> module name or entrypoint could not be found.
>
> do you have some idea regarding this error?

I guess you made a typo in your select statement,
since it calls round, not pround.

It would appear that Firebird cannot load the
dll/so or find the entry point to the function
in the dll.  Did you copy the dll/so to the UDF
subdirectory of your Firebird diretory?  You
could also try adding the extension (.dll or .so)
to the name of the library.  If you are using Linux
you should also check the permissions on the library
and make sure that Firebird can load it.  If this
doesn't work, open the Firebird.conf file and check
what the value for UdfAccess is.

You may also have to change the calling convension of
your function to cdecl, since that is what Firebird expects.

Regards,
Christo
----------------------------------------------------------------------------
NOTICE: Please note that this eMail, and the contents thereof,
is subject to the standard Sasol eMail legal notice which may be found at:
http://www.sasol.com/legalnotices                                                                                                         

If you cannot access the legal notice through the URL attached and you wish
to receive a copy thereof please send an eMail to
[hidden email]
----------------------------------------------------------------------------
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Firebird UDF

Codebue Fabio - P-Soft
In reply to this post by Michael Van Canneyt
I create a pudf.dll library an put in UDF subdirectory of firebird
installation (where you can find other UDFs)

after this I use IBExpert to run the script

DECLARE EXTERNAL FUNCTION pround
DOUBLE PRECISION, INTEGER
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'pround' MODULE_NAME 'pudf';

it run ok, I find another udf under functions category with paremeter set
correctly

Codebue Fabio
.-----------------------------.
  _ \       __|       _||
  __/____|\__ \  _ \  _| _|
 _|       ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web  : www.p-soft.biz
EMail: [hidden email]  

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Michael Van
Canneyt
Sent: Thursday, March 13, 2008 9:52 AM
To: [hidden email]; FPC-Pascal users discussions
Subject: Re: [fpc-pascal] Firebird UDF



On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote:

> This is my UDF source
>
> library pudf;
>   {$mode objfpc}{$H+}
> uses
>   Classes;
>
> function pround(var valore: real; ndec: integer):real;export;
> var
>   i: integer;
>   risultato: real;
>   ndivisore: integer;
> begin
>   risultato:= valore;
>   ndivisore:= 1;
>   for i:= 1 to ndec do
>   begin
>     risultato:= risultato*10;
>     ndivisore:= ndivisore*10;
>   end;
>   result:= round(risultato)/ndivisore;
> end;
>
> exports
>   pround name 'pround';
>
> begin
> end.
>
> but after insert into my fdb with instruction
>
> DECLARE EXTERNAL FUNCTION pround
> DOUBLE PRECISION, INTEGER
> RETURNS DOUBLE PRECISION BY VALUE
> ENTRY_POINT 'pround' MODULE_NAME 'pudf';
>
> if I use it with an instruction like this
>
> select round(123.1233, 2) as nrounded from rdb$database
>
> I have back this error
>
> Invalid token.
> invalid request BLR at offset 59.
> function PROUND is not defined.
> module name or entrypoint could not be found.
>
> do you have some idea regarding this error?

Where did you put the library, what is the library name ?

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Firebird UDF

Michael Van Canneyt


On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote:

> I create a pudf.dll library an put in UDF subdirectory of firebird
> installation (where you can find other UDFs)
>
> after this I use IBExpert to run the script
>
> DECLARE EXTERNAL FUNCTION pround
> DOUBLE PRECISION, INTEGER
> RETURNS DOUBLE PRECISION BY VALUE
> ENTRY_POINT 'pround' MODULE_NAME 'pudf';
>
> it run ok, I find another udf under functions category with paremeter set
> correctly

This is normal; the above just inserts a record in the metadata tables;
Nothing is checked. Can you try changing it to MODULE_NAME 'pudf.dll' ?

Michael.

>
> Codebue Fabio
> .-----------------------------.
>   _ \       __|       _||
>   __/____|\__ \  _ \  _| _|
>  _|       ____/\___/_| \__|
>
> P-Soft di Codebue Fabio & C. sas
> via B.Storti, 19
> 24060 - Chiuduno - BG
> Italy
> Phone: +39.030.839435
> Fax: +39.030.5100306
> Mobile: +39.348.3515786
> .-----------------------------.
> Web  : www.p-soft.biz
> EMail: [hidden email]  
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Michael Van
> Canneyt
> Sent: Thursday, March 13, 2008 9:52 AM
> To: [hidden email]; FPC-Pascal users discussions
> Subject: Re: [fpc-pascal] Firebird UDF
>
>
>
> On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote:
>
> > This is my UDF source
> >
> > library pudf;
> >   {$mode objfpc}{$H+}
> > uses
> >   Classes;
> >
> > function pround(var valore: real; ndec: integer):real;export;
> > var
> >   i: integer;
> >   risultato: real;
> >   ndivisore: integer;
> > begin
> >   risultato:= valore;
> >   ndivisore:= 1;
> >   for i:= 1 to ndec do
> >   begin
> >     risultato:= risultato*10;
> >     ndivisore:= ndivisore*10;
> >   end;
> >   result:= round(risultato)/ndivisore;
> > end;
> >
> > exports
> >   pround name 'pround';
> >
> > begin
> > end.
> >
> > but after insert into my fdb with instruction
> >
> > DECLARE EXTERNAL FUNCTION pround
> > DOUBLE PRECISION, INTEGER
> > RETURNS DOUBLE PRECISION BY VALUE
> > ENTRY_POINT 'pround' MODULE_NAME 'pudf';
> >
> > if I use it with an instruction like this
> >
> > select round(123.1233, 2) as nrounded from rdb$database
> >
> > I have back this error
> >
> > Invalid token.
> > invalid request BLR at offset 59.
> > function PROUND is not defined.
> > module name or entrypoint could not be found.
> >
> > do you have some idea regarding this error?
>
> Where did you put the library, what is the library name ?
>
> Michael.
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Firebird UDF

Codebue Fabio - P-Soft
I try with pudf.dll module name, I try to change function name ... I try a
lot of things...
sigh a so stupid UDF, and I can't create it...

mmm

I'm using firebird 2.0.3 in windows vista environment. pudf was compiled
with fpc 2.0.4 and created with lazarus 0.9.22

sigh!


Codebue Fabio
.-----------------------------.
  _ \       __|       _||
  __/____|\__ \  _ \  _| _|
 _|       ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web  : www.p-soft.biz
EMail: [hidden email]  

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Michael Van
Canneyt
Sent: Thursday, March 13, 2008 10:24 AM
To: FPC-Pascal users discussions
Subject: RE: [fpc-pascal] Firebird UDF



On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote:

> I create a pudf.dll library an put in UDF subdirectory of firebird
> installation (where you can find other UDFs)
>
> after this I use IBExpert to run the script
>
> DECLARE EXTERNAL FUNCTION pround
> DOUBLE PRECISION, INTEGER
> RETURNS DOUBLE PRECISION BY VALUE
> ENTRY_POINT 'pround' MODULE_NAME 'pudf';
>
> it run ok, I find another udf under functions category with paremeter set
> correctly

This is normal; the above just inserts a record in the metadata tables;
Nothing is checked. Can you try changing it to MODULE_NAME 'pudf.dll' ?

Michael.

>
> Codebue Fabio
> .-----------------------------.
>   _ \       __|       _||
>   __/____|\__ \  _ \  _| _|
>  _|       ____/\___/_| \__|
>
> P-Soft di Codebue Fabio & C. sas
> via B.Storti, 19
> 24060 - Chiuduno - BG
> Italy
> Phone: +39.030.839435
> Fax: +39.030.5100306
> Mobile: +39.348.3515786
> .-----------------------------.
> Web  : www.p-soft.biz
> EMail: [hidden email]  
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Michael Van
> Canneyt
> Sent: Thursday, March 13, 2008 9:52 AM
> To: [hidden email]; FPC-Pascal users discussions
> Subject: Re: [fpc-pascal] Firebird UDF
>
>
>
> On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote:
>
> > This is my UDF source
> >
> > library pudf;
> >   {$mode objfpc}{$H+}
> > uses
> >   Classes;
> >
> > function pround(var valore: real; ndec: integer):real;export;
> > var
> >   i: integer;
> >   risultato: real;
> >   ndivisore: integer;
> > begin
> >   risultato:= valore;
> >   ndivisore:= 1;
> >   for i:= 1 to ndec do
> >   begin
> >     risultato:= risultato*10;
> >     ndivisore:= ndivisore*10;
> >   end;
> >   result:= round(risultato)/ndivisore;
> > end;
> >
> > exports
> >   pround name 'pround';
> >
> > begin
> > end.
> >
> > but after insert into my fdb with instruction
> >
> > DECLARE EXTERNAL FUNCTION pround
> > DOUBLE PRECISION, INTEGER
> > RETURNS DOUBLE PRECISION BY VALUE
> > ENTRY_POINT 'pround' MODULE_NAME 'pudf';
> >
> > if I use it with an instruction like this
> >
> > select round(123.1233, 2) as nrounded from rdb$database
> >
> > I have back this error
> >
> > Invalid token.
> > invalid request BLR at offset 59.
> > function PROUND is not defined.
> > module name or entrypoint could not be found.
> >
> > do you have some idea regarding this error?
>
> Where did you put the library, what is the library name ?
>
> Michael.
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: RE: FPC and Profiling software

Graeme Geldenhuys-2
In reply to this post by Jeff Pohlmeyer
Thanks Jeff.

That seems to work fine with my project under Linux. Now I only need
to learn the format and meaning of all the numbers in callgrind.log
file.  But I'm sure the website or man pages will give info on that.

Thanks again...

Regards,
  - Graeme -



On 13/03/2008, Jeff Pohlmeyer <[hidden email]> wrote:

> Graeme Geldenhuys wrote:
>
>  > I'm trying to detect where bottlenecks occur in my code.
>
>
> On Linux, you can get some interesting information with something like this:
>
>  % valgrind --tool=callgrind  [YOUR_APP]  [YOUR_ARGS]
>  % callgrind_annotate --auto=yes --inclusive=yes > callgrind.log
>
>  And then have a look at "callgrind.log"
>
>  To use this, just be sure you do NOT compile your app with -pg !
>
>  More info at http://valgrind.org/
>
>   - Jeff
>  _______________________________________________
>  fpc-pascal maillist  -  [hidden email]
>  http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>


--
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Firebird UDF

zaher dirkey
In reply to this post by Codebue Fabio - P-Soft
try to add "cdecl"

|    function pround(var valore: real; ndec: integer):real; cdecl; export;

On Thu, Mar 13, 2008 at 11:43 AM, Codebue Fabio - P-Soft <[hidden email]> wrote:
I try with pudf.dll module name, I try to change function name ... I try a
lot of things...
sigh a so stupid UDF, and I can't create it...

mmm

I'm using firebird 2.0.3 in windows vista environment. pudf was compiled
with fpc 2.0.4 and created with lazarus 0.9.22

sigh!


Codebue Fabio
.-----------------------------.
 _ \       __|       _||
 __/____|\__ \  _ \  _| _|
 _|       ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web  : www.p-soft.biz
EMail: [hidden email]

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Michael Van
Canneyt
Sent: Thursday, March 13, 2008 10:24 AM
To: FPC-Pascal users discussions
Subject: RE: [fpc-pascal] Firebird UDF



On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote:

> I create a pudf.dll library an put in UDF subdirectory of firebird
> installation (where you can find other UDFs)
>
> after this I use IBExpert to run the script
>
> DECLARE EXTERNAL FUNCTION pround
> DOUBLE PRECISION, INTEGER
> RETURNS DOUBLE PRECISION BY VALUE
> ENTRY_POINT 'pround' MODULE_NAME 'pudf';
>
> it run ok, I find another udf under functions category with paremeter set
> correctly

This is normal; the above just inserts a record in the metadata tables;
Nothing is checked. Can you try changing it to MODULE_NAME 'pudf.dll' ?

Michael.

>
> Codebue Fabio
> .-----------------------------.
>   _ \       __|       _||
>   __/____|\__ \  _ \  _| _|
>  _|       ____/\___/_| \__|
>
> P-Soft di Codebue Fabio & C. sas
> via B.Storti, 19
> 24060 - Chiuduno - BG
> Italy
> Phone: +39.030.839435
> Fax: +39.030.5100306
> Mobile: +39.348.3515786
> .-----------------------------.
> Web  : www.p-soft.biz
> EMail: [hidden email]
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Michael Van
> Canneyt
> Sent: Thursday, March 13, 2008 9:52 AM
> To: [hidden email]; FPC-Pascal users discussions
> Subject: Re: [fpc-pascal] Firebird UDF
>
>
>
> On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote:
>
> > This is my UDF source
> >
> > library pudf;
> >   {$mode objfpc}{$H+}
> > uses
> >   Classes;
> >
> > function pround(var valore: real; ndec: integer):real;export;
> > var
> >   i: integer;
> >   risultato: real;
> >   ndivisore: integer;
> > begin
> >   risultato:= valore;
> >   ndivisore:= 1;
> >   for i:= 1 to ndec do
> >   begin
> >     risultato:= risultato*10;
> >     ndivisore:= ndivisore*10;
> >   end;
> >   result:= round(risultato)/ndivisore;
> > end;
> >
> > exports
> >   pround name 'pround';
> >
> > begin
> > end.
> >
> > but after insert into my fdb with instruction
> >
> > DECLARE EXTERNAL FUNCTION pround
> > DOUBLE PRECISION, INTEGER
> > RETURNS DOUBLE PRECISION BY VALUE
> > ENTRY_POINT 'pround' MODULE_NAME 'pudf';
> >
> > if I use it with an instruction like this
> >
> > select round(123.1233, 2) as nrounded from rdb$database
> >
> > I have back this error
> >
> > Invalid token.
> > invalid request BLR at offset 59.
> > function PROUND is not defined.
> > module name or entrypoint could not be found.
> >
> > do you have some idea regarding this error?
>
> Where did you put the library, what is the library name ?
>
> Michael.
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



--
Zaher Dirkey
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Firebird UDF

zaher dirkey
Hi Again,
try to copy ib_util.dll to system folder, or make PATH to Firebird bin folder.

and
 (var valore: Double
not "real"

On Thu, Mar 13, 2008 at 12:44 PM, zaher dirkey <[hidden email]> wrote:
try to add "cdecl"

|    function pround(var valore: real; ndec: integer):real; cdecl; export;


On Thu, Mar 13, 2008 at 11:43 AM, Codebue Fabio - P-Soft <[hidden email]> wrote:
I try with pudf.dll module name, I try to change function name ... I try a
lot of things...
sigh a so stupid UDF, and I can't create it...

mmm

I'm using firebird 2.0.3 in windows vista environment. pudf was compiled
with fpc 2.0.4 and created with lazarus 0.9.22

sigh!


Codebue Fabio
.-----------------------------.
 _ \       __|       _||
 __/____|\__ \  _ \  _| _|
 _|       ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web  : www.p-soft.biz
EMail: [hidden email]

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Michael Van
Canneyt
Sent: Thursday, March 13, 2008 10:24 AM
To: FPC-Pascal users discussions
Subject: RE: [fpc-pascal] Firebird UDF



On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote:

> I create a pudf.dll library an put in UDF subdirectory of firebird
> installation (where you can find other UDFs)
>
> after this I use IBExpert to run the script
>
> DECLARE EXTERNAL FUNCTION pround
> DOUBLE PRECISION, INTEGER
> RETURNS DOUBLE PRECISION BY VALUE
> ENTRY_POINT 'pround' MODULE_NAME 'pudf';
>
> it run ok, I find another udf under functions category with paremeter set
> correctly

This is normal; the above just inserts a record in the metadata tables;
Nothing is checked. Can you try changing it to MODULE_NAME 'pudf.dll' ?

Michael.

>
> Codebue Fabio
> .-----------------------------.
>   _ \       __|       _||
>   __/____|\__ \  _ \  _| _|
>  _|       ____/\___/_| \__|
>
> P-Soft di Codebue Fabio & C. sas
> via B.Storti, 19
> 24060 - Chiuduno - BG
> Italy
> Phone: +39.030.839435
> Fax: +39.030.5100306
> Mobile: +39.348.3515786
> .-----------------------------.
> Web  : www.p-soft.biz
> EMail: [hidden email]
>
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Michael Van
> Canneyt
> Sent: Thursday, March 13, 2008 9:52 AM
> To: [hidden email]; FPC-Pascal users discussions
> Subject: Re: [fpc-pascal] Firebird UDF
>
>
>
> On Thu, 13 Mar 2008, Codebue Fabio - P-Soft wrote:
>
> > This is my UDF source
> >
> > library pudf;
> >   {$mode objfpc}{$H+}
> > uses
> >   Classes;
> >
> > function pround(var valore: real; ndec: integer):real;export;
> > var
> >   i: integer;
> >   risultato: real;
> >   ndivisore: integer;
> > begin
> >   risultato:= valore;
> >   ndivisore:= 1;
> >   for i:= 1 to ndec do
> >   begin
> >     risultato:= risultato*10;
> >     ndivisore:= ndivisore*10;
> >   end;
> >   result:= round(risultato)/ndivisore;
> > end;
> >
> > exports
> >   pround name 'pround';
> >
> > begin
> > end.
> >
> > but after insert into my fdb with instruction
> >
> > DECLARE EXTERNAL FUNCTION pround
> > DOUBLE PRECISION, INTEGER
> > RETURNS DOUBLE PRECISION BY VALUE
> > ENTRY_POINT 'pround' MODULE_NAME 'pudf';
> >
> > if I use it with an instruction like this
> >
> > select round(123.1233, 2) as nrounded from rdb$database
> >
> > I have back this error
> >
> > Invalid token.
> > invalid request BLR at offset 59.
> > function PROUND is not defined.
> > module name or entrypoint could not be found.
> >
> > do you have some idea regarding this error?
>
> Where did you put the library, what is the library name ?
>
> Michael.
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal



--
Zaher Dirkey



--
Zaher Dirkey
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Firebird UDF

Stephano-2
In reply to this post by Codebue Fabio - P-Soft
Codebue Fabio - P-Soft wrote:

> This is my UDF source
>
> library pudf;
>   {$mode objfpc}{$H+}
> uses
>   Classes;
>
> function pround(var valore: real; ndec: integer):real;export;
> var
>   i: integer;
>   risultato: real;
>   ndivisore: integer;
> begin
>   risultato:= valore;
>   ndivisore:= 1;
>   for i:= 1 to ndec do
>   begin
>     risultato:= risultato*10;
>     ndivisore:= ndivisore*10;
>   end;
>   result:= round(risultato)/ndivisore;
> end;
>
> exports
>   pround name 'pround';
>
> begin
> end.
>
> but after insert into my fdb with instruction
>
> DECLARE EXTERNAL FUNCTION pround
> DOUBLE PRECISION, INTEGER
> RETURNS DOUBLE PRECISION BY VALUE
> ENTRY_POINT 'pround' MODULE_NAME 'pudf';
>
> if I use it with an instruction like this
>
> select round(123.1233, 2) as nrounded from rdb$database
>
> I have back this error
>
> Invalid token.
> invalid request BLR at offset 59.
> function PROUND is not defined.
> module name or entrypoint could not be found.
>
> do you have some idea regarding this error?

1- You should use cdecl for your function

2- you should use pudf_pround as module entry name

3- use double instead of real

I hope this helps.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Firebird UDF

Codebue Fabio - P-Soft
nothing todo...
ok restart:
library pudf;

{$mode objfpc}{$H+}

uses
  Classes,
  p_func in 'p_func.pas';

exports
  pround name 'p_round';

{$R pudf.res}

begin

//  DECLARE EXTERNAL FUNCTION pround
//   DOUBLE PRECISION, INTEGER
//   RETURNS DOUBLE PRECISION BY VALUE
//  ENTRY_POINT 'pudf_pround'  MODULE_NAME 'pudf';

end.                        

and

unit p_func;

{$mode objfpc}{$H+}

interface
  function p_round(var valore: double; ndec: integer): double; cdecl;

implementation

uses
  Classes, SysUtils;

function p_round(var valore: double; ndec: integer): double; cdecl;
var
  i: integer;
  risultato: double;
  ndivisore: integer;
begin

  risultato:= valore;
  ndivisore:= 1;
  for i:= 1 to ndec do
  begin
    risultato:= risultato*10;
    ndivisore:= ndivisore*10;
  end;

  result:= round(risultato)/ndivisore;
end;
end.      

someone can compile and install?

I can... but when I try to execute

select round(123.1233, 2) as nrounded from rdb$database

always some error!!!



Codebue Fabio
.-----------------------------.
  _ \       __|       _||
  __/____|\__ \  _ \  _| _|
 _|       ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web  : www.p-soft.biz
EMail: [hidden email]  


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: RE: FPC and Profiling software

Bartek-9
In reply to this post by Graeme Geldenhuys-2
On Thursday 13 March 2008 11:26:49 Graeme Geldenhuys wrote:
> Thanks Jeff.
>
> That seems to work fine with my project under Linux. Now I only need
> to learn the format and meaning of all the numbers in callgrind.log
> file.  But I'm sure the website or man pages will give info on that.

kcachegrind is a excellent front-end for valgrind. Depending on your distro this should be in kde-devel.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Firebird UDF

Stephano-2
In reply to this post by Codebue Fabio - P-Soft
Codebue Fabio - P-Soft wrote:

> nothing todo...
> ok restart:
> library pudf;
>
> {$mode objfpc}{$H+}
>
> uses
>   Classes,
>   p_func in 'p_func.pas';
>
> exports
>   pround name 'p_round';
>
> {$R pudf.res}
>
> begin
>
> //  DECLARE EXTERNAL FUNCTION pround
> //   DOUBLE PRECISION, INTEGER
> //   RETURNS DOUBLE PRECISION BY VALUE
> //  ENTRY_POINT 'pudf_pround'  MODULE_NAME 'pudf';
>
> end.                        
>
> and
>
> unit p_func;
>
> {$mode objfpc}{$H+}
>
> interface
>   function p_round(var valore: double; ndec: integer): double; cdecl;
>
> implementation
>
> uses
>   Classes, SysUtils;
>
> function p_round(var valore: double; ndec: integer): double; cdecl;
> var
>   i: integer;
>   risultato: double;
>   ndivisore: integer;
> begin
>
>   risultato:= valore;
>   ndivisore:= 1;
>   for i:= 1 to ndec do
>   begin
>     risultato:= risultato*10;
>     ndivisore:= ndivisore*10;
>   end;
>
>   result:= round(risultato)/ndivisore;
> end;
> end.      
>
> someone can compile and install?
>
> I can... but when I try to execute
>
> select round(123.1233, 2) as nrounded from rdb$database
>
> always some error!!!

You are exporting now the function as p_round. So I guess your entry
point should be pudf_p_round.

Furthermore, your sql includes round and not pround!

What is the error message you got?
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Firebird UDF

Codebue Fabio - P-Soft
 


Codebue Fabio
.-----------------------------.
  _ \       __|       _||
  __/____|\__ \  _ \  _| _|
 _|       ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web  : www.p-soft.biz
EMail: [hidden email]  

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Stephano
Sent: Thursday, March 13, 2008 8:09 PM
To: FPC-Pascal users discussions
Subject: Re: [fpc-pascal] Firebird UDF

Codebue Fabio - P-Soft wrote:

> nothing todo...
> ok restart:
> library pudf;
>
> {$mode objfpc}{$H+}
>
> uses
>   Classes,
>   p_func in 'p_func.pas';
>
> exports
>   pround name 'p_round';
>
> {$R pudf.res}
>
> begin
>
> //  DECLARE EXTERNAL FUNCTION pround
> //   DOUBLE PRECISION, INTEGER
> //   RETURNS DOUBLE PRECISION BY VALUE
> //  ENTRY_POINT 'pudf_pround'  MODULE_NAME 'pudf';
>
> end.                        
>
> and
>
> unit p_func;
>
> {$mode objfpc}{$H+}
>
> interface
>   function p_round(var valore: double; ndec: integer): double; cdecl;
>
> implementation
>
> uses
>   Classes, SysUtils;
>
> function p_round(var valore: double; ndec: integer): double; cdecl;
> var
>   i: integer;
>   risultato: double;
>   ndivisore: integer;
> begin
>
>   risultato:= valore;
>   ndivisore:= 1;
>   for i:= 1 to ndec do
>   begin
>     risultato:= risultato*10;
>     ndivisore:= ndivisore*10;
>   end;
>
>   result:= round(risultato)/ndivisore;
> end;
> end.      
>
> someone can compile and install?
>
> I can... but when I try to execute
>
> select round(123.1233, 2) as nrounded from rdb$database
>
> always some error!!!

You are exporting now the function as p_round. So I guess your entry
point should be pudf_p_round.

Furthermore, your sql includes round and not pround!

What is the error message you got?
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Firebird UDF

Codebue Fabio - P-Soft
In reply to this post by Stephano-2
I register my udfp with command

DECLARE EXTERNAL FUNCTION pround
  DOUBLE PRECISION, INTEGER
   RETURNS DOUBLE PRECISION BY VALUE
  ENTRY_POINT 'pudf_p_round'  MODULE_NAME 'pudf';

and test with this sql

select round(123.1233, 2) as nrounded from rdb$database

returning error

Invalid token.
invalid request BLR at offset 59.
function PROUND is not defined.
module name or entrypoint could not be found.


I try to register with
ENTRY_POINT 'p_round' or
MODULE_NAME 'pudf.dll'

nothing todo!!!

I have to set particular linker or compiler parameters?

Codebue Fabio
.-----------------------------.
  _ \       __|       _||
  __/____|\__ \  _ \  _| _|
 _|       ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web  : www.p-soft.biz
EMail: [hidden email]  

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Stephano
Sent: Thursday, March 13, 2008 8:09 PM
To: FPC-Pascal users discussions
Subject: Re: [fpc-pascal] Firebird UDF

Codebue Fabio - P-Soft wrote:

> nothing todo...
> ok restart:
> library pudf;
>
> {$mode objfpc}{$H+}
>
> uses
>   Classes,
>   p_func in 'p_func.pas';
>
> exports
>   pround name 'p_round';
>
> {$R pudf.res}
>
> begin
>
> //  DECLARE EXTERNAL FUNCTION pround
> //   DOUBLE PRECISION, INTEGER
> //   RETURNS DOUBLE PRECISION BY VALUE
> //  ENTRY_POINT 'pudf_pround'  MODULE_NAME 'pudf';
>
> end.                        
>
> and
>
> unit p_func;
>
> {$mode objfpc}{$H+}
>
> interface
>   function p_round(var valore: double; ndec: integer): double; cdecl;
>
> implementation
>
> uses
>   Classes, SysUtils;
>
> function p_round(var valore: double; ndec: integer): double; cdecl;
> var
>   i: integer;
>   risultato: double;
>   ndivisore: integer;
> begin
>
>   risultato:= valore;
>   ndivisore:= 1;
>   for i:= 1 to ndec do
>   begin
>     risultato:= risultato*10;
>     ndivisore:= ndivisore*10;
>   end;
>
>   result:= round(risultato)/ndivisore;
> end;
> end.      
>
> someone can compile and install?
>
> I can... but when I try to execute
>
> select round(123.1233, 2) as nrounded from rdb$database
>
> always some error!!!

You are exporting now the function as p_round. So I guess your entry
point should be pudf_p_round.

Furthermore, your sql includes round and not pround!

What is the error message you got?
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

RE: Firebird UDF

Codebue Fabio - P-Soft
In reply to this post by zaher dirkey
I learn about all your tips... but nothing todo. I try to summarize
I'm using firebird 2.0.3 in windows vista environment. pudf was compiled with fpc 2.0.4 and created with lazarus 0.9.22
 
project file
 
     library pudf;
 
{$mode objfpc}{$H+}
 
uses
  Classes,
  p_func in 'p_func.pas';
 
exports
  p_round name 'p_round';
 
{$R pudf.res}
 
begin        
end.
function file
 
unit p_func;
 
{$mode objfpc}{$H+}
 
interface
  function p_round(var valore: double; ndec: integer): double; cdecl;
 
implementation
 
uses
  Classes, SysUtils;
 
function p_round(var valore: double; ndec: integer): double; cdecl;
var
  i: integer;
  risultato: double;
  ndivisore: integer;
begin
 
  risultato:= valore;
  ndivisore:= 1;
  for i:= 1 to ndec do
  begin
    risultato:= risultato*10;
    ndivisore:= ndivisore*10;
  end;
 
  Result:= round(risultato)/ndivisore;
end;
end.                                 
 
Declare command:
 
 
 
 
test commnand
 
select P_ROUND(123.1233, 2) as nrounded from rdb$database
 
 
error
 
Invalid token.
invalid request BLR at offset 59.
function P_ROUND is not defined.
module name or entrypoint could not be found.
 
 

Codebue Fabio
.-----------------------------.
  _ \       __|       _||
  __/____|\__ \  _ \  _| _|
 _|       ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web  : www.p-soft.biz
EMail: [hidden email] 


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Firebird UDF

Stephano-2
In reply to this post by Codebue Fabio - P-Soft
>> nothing todo...
>> ok restart:
>> library pudf;
>>
>> {$mode objfpc}{$H+}
>>
>> uses
>>   Classes,
>>   p_func in 'p_func.pas';
>>
>> exports
>>   pround name 'p_round';
>>
>> {$R pudf.res}
>>
>> begin
>>
>> //  DECLARE EXTERNAL FUNCTION pround
>> //   DOUBLE PRECISION, INTEGER
>> //   RETURNS DOUBLE PRECISION BY VALUE
>> //  ENTRY_POINT 'pudf_pround'  MODULE_NAME 'pudf';
>>
>> end.                        
>>
>> and
>>
>> unit p_func;
>>
>> {$mode objfpc}{$H+}
>>
>> interface
>>   function p_round(var valore: double; ndec: integer): double; cdecl;
>>
>> implementation
>>
>> uses
>>   Classes, SysUtils;
>>
>> function p_round(var valore: double; ndec: integer): double; cdecl;
>> var
>>   i: integer;
>>   risultato: double;
>>   ndivisore: integer;
>> begin
>>
>>   risultato:= valore;
>>   ndivisore:= 1;
>>   for i:= 1 to ndec do
>>   begin
>>     risultato:= risultato*10;
>>     ndivisore:= ndivisore*10;
>>   end;
>>
>>   result:= round(risultato)/ndivisore;
>> end;
>> end.      
>>
>> someone can compile and install?
>>
>> I can... but when I try to execute
>>
>> select round(123.1233, 2) as nrounded from rdb$database
>>
>> always some error!!!

- Entry point should be p_round only in this case

- Adding also 'export' in the function declaration should help:

function p_round(var valore: double; ndec: integer): double; cdecl; export;

- The following needs to be corrected as well:
exports p_round name 'p_round';
_________^
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
12