Recent

Author Topic: Exploring code in Lazarus  (Read 475 times)

440bx

  • Hero Member
  • *****
  • Posts: 3161
Exploring code in Lazarus
« 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.
FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 SP1 64bit.

dje

  • Full Member
  • ***
  • Posts: 124
Re: Exploring code in Lazarus
« Reply #1 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
« Last Edit: October 01, 2022, 05:05:26 am by dje »

440bx

  • Hero Member
  • *****
  • Posts: 3161
Re: Exploring code in Lazarus
« Reply #2 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)

FPC v3.0.4 and Lazarus 1.8.2 on Windows 7 SP1 64bit.

Arioch

  • Sr. Member
  • ****
  • Posts: 414
Re: Exploring code in Lazarus
« Reply #3 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

MarkMLl

  • Hero Member
  • *****
  • Posts: 5586
Re: Exploring code in Lazarus
« Reply #4 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
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Arioch

  • Sr. Member
  • ****
  • Posts: 414
Re: Exploring code in Lazarus
« Reply #5 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.
« Last Edit: October 01, 2022, 05:36:07 pm by Arioch »

 

TinyPortal © 2005-2018