[Lazarus] (Local) variable value hints

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

[Lazarus] (Local) variable value hints

Free Pascal - Lazarus mailing list
Bearing in mind things like the %H hint that Lazarus uses to suppress
warning messages, is there anything comparable that can be applied to a
variable so that when the IDE pops up a value during debugging it will
always be shown in a certain format?

..
end else begin
   euCount := cardEsu;
   euVector := sysEuVector <=== THIS ONLY MEANINGFUL AS HEX OR BINARY
end;
Assert(euCount * euVector > 0, 'Bad EU count or vector');

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] (Local) variable value hints

Free Pascal - Lazarus mailing list
On 06.06.2017 21:54, Mark Morgan Lloyd via Lazarus wrote:
> Bearing in mind things like the %H hint that Lazarus uses to suppress
> warning messages, is there anything comparable that can be applied to
> a variable so that when the IDE pops up a value during debugging it
> will always be shown in a certain format?
>
> ..
> end else begin
>   euCount := cardEsu;
>   euVector := sysEuVector <=== THIS ONLY MEANINGFUL AS HEX OR BINARY

You can define your own value formatter with
TBaseDebugManagerIntf.RegisterValueFormatter

But: it works on a type-basis and not variable name basis. So define a
specific type euVector:

   TeuVector = type Integer; // or type whatever

and then register it with RegisterValueFormatter(skSimple, 'TeuVector',
@MyFormatFunction);

See how TDateTime is handled in ide/debugmanager.pas

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

Re: [Lazarus] (Local) variable value hints

Free Pascal - Lazarus mailing list
On 06/06/17 20:00, Ondrej Pokorny via Lazarus wrote:
> On 06.06.2017 21:54, Mark Morgan Lloyd via Lazarus wrote:> Bearing in
> mind things like the %H hint that Lazarus uses to suppress > warning
> messages, is there anything comparable that can be applied to > a
> variable so that when the IDE pops up a value during debugging it > will
> always be shown in a certain format?>> ..> end else begin>   euCount :=
> cardEsu;>   euVector := sysEuVector <=== THIS ONLY MEANINGFUL AS HEX OR
> BINARY

> You can define your own value formatter with
> TBaseDebugManagerIntf.RegisterValueFormatter
> But: it works on a type-basis and not variable name basis. So define a
> specific type euVector:
>   TeuVector = type Integer; // or type whatever
> and then register it with RegisterValueFormatter(skSimple, 'TeuVector',
> @MyFormatFunction);
> See how TDateTime is handled in ide/debugmanager.pas

So does that mean that the IDE has to be tailored for a specific project?

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] (Local) variable value hints

Free Pascal - Lazarus mailing list
 > So does that mean that the IDE has to be tailored for a specific project?

Yes. Install a custom package to extend the IDE.

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

Re: [Lazarus] (Local) variable value hints

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On 06/06/2017 20:54, Mark Morgan Lloyd via Lazarus wrote:

> Bearing in mind things like the %H hint that Lazarus uses to suppress
> warning messages, is there anything comparable that can be applied to
> a variable so that when the IDE pops up a value during debugging it
> will always be shown in a certain format?
>
> ..
> end else begin
>   euCount := cardEsu;
>   euVector := sysEuVector <=== THIS ONLY MEANINGFUL AS HEX OR BINARY
> end;
> Assert(euCount * euVector > 0, 'Bad EU count or vector');
>
The easiest way is to use the watch window.

Watches can IIRC be configured via their properties.
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] (Local) variable value hints

Free Pascal - Lazarus mailing list
On 07/06/17 12:15, Martin Frb via Lazarus wrote:
> On 06/06/2017 20:54, Mark Morgan Lloyd via Lazarus wrote:> Bearing in
> mind things like the %H hint that Lazarus uses to suppress > warning
> messages, is there anything comparable that can be applied to > a
> variable so that when the IDE pops up a value during debugging it > will
> always be shown in a certain format?>> ..> end else begin>   euCount :=
> cardEsu;>   euVector := sysEuVector <=== THIS ONLY MEANINGFUL AS HEX OR
> BINARY> end;> Assert(euCount * euVector > 0, 'Bad EU count or
> vector');

>The easiest way is to use the watch window.
> Watches can IIRC be configured via their properties.--

Yes, but I was thinking about the case when a value pops up unbidden
during normal stepping-through.

Can the default witching format be changed? Hex might be more appropriate.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] (Local) variable value hints

Free Pascal - Lazarus mailing list
On 07/06/2017 14:42, Mark Morgan Lloyd via Lazarus wrote:
>
> Yes, but I was thinking about the case when a value pops up unbidden
> during normal stepping-through.
>
> Can the default witching format be changed? Hex might be more
> appropriate.
>

Generally yes, but depends how...

A simple integer could (in the hint) be shown in dec and hex. (the hint
has plenty of space for an integer.)
But in other windows that may not be wanted. The column of the watch
window has less space, so showing both (without the user requesting) may
be too much.

The hint is interactive, so there could be options added to the hint,
and the hint could remember (based on type, type and name, or
type/name/context).

That is if someone wants to implement it.

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

Re: [Lazarus] (Local) variable value hints

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On 07.06.2017 13:20, Ondrej Pokorny via Lazarus wrote:
> > So does that mean that the IDE has to be tailored for a specific
> project?
>
> Yes. Install a custom package to extend the IDE.

Or: extend the IDE with some default formatters, add an IDE option page
(and/or project option page) where the user can define formatter
overloads for custom types without needing to recompile the IDE. Send
the patch over to mantis - I'll apply it to trunk.

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