Lazarus

Using the Lazarus IDE => General => Topic started by: 440bx on October 01, 2022, 03:55:08 am

Title: Exploring code in Lazarus
Post by: 440bx on October 01, 2022, 03:55:08 am
Hello,

The Lazarus "Code Explorer" comes in handy quite often.

I was wondering if, somewhere/somehow, Lazarus can show a list of where a particular procedure/function is called (in addition to where it's defined.)

That's my question: does Lazarus show a list of _where_ a specific function/procedure is called and, if the answer is yes, how do I get it to show me that list ?

Thank you for your help.
Title: Re: Exploring code in Lazarus
Post by: dje on October 01, 2022, 05:03:53 am
Right click: Find->Find Identifier References...

Edit: Also available from the Search menu, and via Ctrl+Shift+I
Title: Re: Exploring code in Lazarus
Post by: 440bx on October 01, 2022, 05:46:41 am
Right click: Find->Find Identifier References...

Edit: Also available from the Search menu, and via Ctrl+Shift+I
Thank you.  It works great with variables and other identifiers but, when I tell it to find a function or procedure, it doesn't find any references/calls, not even "find in files" (with all project files) finds any references. 

NOTE: using Lazarus 2.2RC1  (haven't tried with latest)

Title: Re: Exploring code in Lazarus
Post by: Arioch on October 01, 2022, 04:15:26 pm
maybe you did not explicitly included those files in the project as top-level sources. I'd rather make grep (F-i-F) to look into select folders and their subfolers for *.pas;*.inc;*.pp, than merely "in project files"

did you set extra checkboxes in F-i-F ? sometimes things like "case sensitive" or "whole words only" can deny matches, especially id the copied text for searching contained spaces or brackets or other non-alphanumerics
Title: Re: Exploring code in Lazarus
Post by: MarkMLl on October 01, 2022, 04:41:44 pm
I was wondering if, somewhere/somehow, Lazarus can show a list of where a particular procedure/function is called (in addition to where it's defined.)

I think the problem there is that if looked at globally, Lazarus (or a comparable tool) would show you all definitions of a function with a particular name irrespective of scope and parameter types. Similarly, if it were asked to look for invocations, it would only match by name.

This is very similar to the issue of the IBM mainframe expert who was enthusiastic about the feasibility of a cross compiler (i.e. FPC running on a PC but targetting an S/370 etc.) but lost interest when somebody (possibly Jonas) pointed out that he could /not/ be provided with an xref listing because of the number of places where e.g. objects in the compiler's AST were processed by functions determined at runtime.

I agree it would be nice to have. I'm not sure it's feasible.

MarkMLl
Title: Re: Exploring code in Lazarus
Post by: Arioch on October 01, 2022, 05:34:01 pm
well, xref in ASM meant exactly what on the tag, "reference".

it did not mean that symbol (could be variable, not necessarily code point) was mentioned, not accessed

surely FPC can list all the places the function name was mentioned and that would be needed to be changed in case of refactoring.

as for execution - it was always a dynamic issue. Even in a language without function pointers and virtual members - you still can have a funciton mentioned in unreachable code, so there would be only an xref without execution.

OOP provides for execution without xref, surely. But hey, so did assembler, just make a fall-through function without "return" command :-)
I guess everyone and his dog used to make their own CRT for TP, and i think i used fall-through functions in mine.
TinyPortal © 2005-2018