Recent

Author Topic: Poll: Watches and DisplayFormat => How do you think data should be displayed  (Read 16429 times)

Thaddy

  • Hero Member
  • *****
  • Posts: 15639
  • Censorship about opinions does not belong here.
Yes, because you should not make the mistake that multi-dimensioned arrays are always consecutive memory. They may align on the boundary of the dimensions - in fact they do depending on declaration - and that is much harder to express in a debugger. Maybe I expressed it not accurate enough.
« Last Edit: August 30, 2024, 03:29:10 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10293
  • Debugger - SynEdit - and more
    • wiki
Yes, because you should not make the mistake that multi-dimensioned arrays are always consecutive memory. They may align on the boundary of the dimensions - in fact they do depending on declaration - and that is much harder to express in a debugger. Maybe I expressed it not accurate enough.
Maybe, you inaccurately interpreted my text as making such an assumption? Nothing that I described relies in any way on where in memory the data is. Nor is the resulting display giving any info on where the information resides, merely which size (given as count of elements) individual parts of the data have.




OK, I just figured out a potential point of misunderstanding....

In my text I declared 2 numbered cases. But I made no question about them (neither if, nor how they may be applicable or any other question).
I actually made a bold (literally bold text) statement, that I wanted to talk about the first of those 2 cases only.

I then made a question with a list of 3 possible answers (each starting with a dash).

When you replied, I took it as an answer to my question (because it did not state, that it ignored my question and potentially was a comment on something else, and it did refer to "second" which identifies one of the proposed replies from my dashed list).
Since the memory can be aligned on dimensions, I think the only correct option would be the second one.

The 2nd proposed reply was
- be optimistic and assume the other checks would have succeeded
Your answer made no sense at all.

But then, if you referred to something else, was it just the "case list" or the "case list" in combination with some special scenario described somewhere in my post, and if so what was the scenario?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10293
  • Debugger - SynEdit - and more
    • wiki
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #92 on: September 01, 2024, 12:30:28 am »
An array (Including an multidimensional/nested array) can be the most outer (nested) array in a value.
Or it can be not an most outer (nested) array.

Example
Code: Pascal  [Select][+][-]
  1. var foo: array[0..3,0..3] of record   // most outer nested array
  2.    bar: array[0..3,0..3] of byte;  // not most outer
  3. end;
  4. var foo: array of array of record    // most outer nested array
  5.   bar: array of array of byte;  // not most outer
  6. end;
  7. var xyz: record  
  8.   foo: array of array of record   // most outer nested array (even though it is nested, but not in an array)
  9.     bar: array of array of byte;  
  10.   end;
  11. end;

What is a good short name for the "not most outer" ?

440bx

  • Hero Member
  • *****
  • Posts: 4524
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #93 on: September 01, 2024, 12:59:59 am »
What is a good short name for the "not most outer" ?
terms that come to mind are: "outer array", "outermost array", "boundary array", "topmost array", "enclosing array".

I like "outermost", I think that one has the most obvious meaning.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10293
  • Debugger - SynEdit - and more
    • wiki
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #94 on: September 01, 2024, 01:04:11 am »
What is a good short name for the "not most outer" ?
terms that come to mind are: "outer array", "outermost array", "boundary array", "topmost array", "enclosing array".

I like "outermost", I think that one has the most obvious meaning.

What is a good short name for the "not most outer" ?

Any of them, as there can be many levels.

- It's not nested, because "array of array" is nested.
- It's not "just in a structure", it only counts if it is in an outer array



Background:

For configuring the "len" prefix, and when it is and isn't shown, there will be.

- A depth, in the current nested-run: Len=3: ( Len=2: (1,2), Len=1: (1),  Len=2: (1,2) )
  if the "depth" says "0 nested" then only "len=3" appears.
- An option, if that is done only for the outermost array (even if that is in a structure), or if it is repeated on the "inner" arrays too.

I am aware, it seems strange to not just go for: top level(not nested in any way) versus any-nested.

But, for the global Displayformat settings (tools options) the plan is, that each default can be given for
- most outer of everything
- nested in any form

So that allows to set a more verbose numeric default for watches that return just a single number, yet for watches that have structures/arrays with many numbers the format can be more brief.

Yet, this option wont be in the "watch properties" => if you configure for a specific watch, you (usually) know if it is a structure. So then you can directly set numbers to the brief format. (and same for any other).

Except, the in watch properties you only have one setting for array. You can change that if the array is in a structure. But if the array is in a structure in an outer array, then the one setting applies for both. And to cover that case, there needs to (would be nice to be) a switch.

And that switch therefore only cares about the existence of an outer array run.

Since multidimensional arrays will have settings (either to combine as han requested), or a depth that is relative to the multidimensional run), this only applies if array that are in other arrays are separated by any non-array (structure, pointer, ...)

« Last Edit: September 01, 2024, 01:18:02 am by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10293
  • Debugger - SynEdit - and more
    • wiki
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #95 on: September 01, 2024, 01:27:52 am »
Also, I am still contemplating how exactly to go about those "defaults for nested"

Because, in case of the array length, it already includes the "depth" for the current multi-dimensional.

Also because in the watch-properties itself you can only give one config for array or struct (even if there are nested // or nested runs).

So that brings up some issues.
A default for nested, can only be used, if it is nested in any type that differs from the current.
E.g. a default for nested structure applies to data nested in an array. But not to data nested in an outer structure.
Otherwise at least array and structure also need configs for nested in watch properties.

That however would create a new issue:
Config for the nav bar, can be nested within a multi dimensional array (with no need to interrupt the run)
But the len prefix can only be ?nested? per "run".
So that gets a bit crazy....

440bx

  • Hero Member
  • *****
  • Posts: 4524
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #96 on: September 01, 2024, 04:50:31 am »
What is a good short name for the "not most outer" ?
the "not" flew over my head ;)

Taking the "not" into account, I'd go for "innermost" or if wanting to specify any array except the outermost then "not outermost" (which is basically "not most outer" but in two words instead of 3, which is valid English - ask Joanna ;) )  or  "inner array(s)" (which basically precludes the outermost since that one isn't inside another array.)

IOW, generically any "not most outer" is an "inner array".


(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10293
  • Debugger - SynEdit - and more
    • wiki
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #97 on: September 03, 2024, 07:28:15 pm »
b) The information len=3 is correct but it is a three dimensional array.

Now you can chose to have either
Code: Text  [Select][+][-]
  1. Test: array [0..2,0..1] of integer;
  2.  
  3. Len=(3, 2): ((99, 0), (0, 0), (0, 0))
  4. Len=3: (Len=2: (99, 0), Len=2: (0, 0), Len=2: (0, 0))
  5. Len=3: ((99, 0), (0, 0), (0, 0))
  6. ((99, 0), (0, 0), (0, 0))

Or, if you have something like
Code: Text  [Select][+][-]
  1. Test2: array [0..2,0..1] of record
  2.   Foo: array [0..2,0..1] of integer;
  3. end;
  4.  
  5. Len=(3, 2):
  6. (((Foo: Len=(3, 2): ((0, 0), (0, 99), (0, 0));), (Foo: Len=(3, 2): ((0, 0), (0, 0), (0, 0));)),
  7. ((Foo: Len=(3, 2): ((0, 0), (0, 0), (0, 0));), (Foo: Len=(3, 2): ((0, 0), (0, 0), (0, 0));)),
  8. ((Foo: Len=(3, 2): ((0, 0), (0, 0), (0, 0));), (Foo: Len=(3, 2): ((0, 0), (0, 0), (0, 0));))
  9. )
The "multi-dim array len" start for eache multi-dim array.




Now one issue is setting up a default.

The "combined len" will always cover all dimensions.

But in the top example the repeated "Len=2" may be too much, after all it is easily visible that there are just 2 elements. And even worse, for a list of empty arrays.
So, yes you can custom configure that when the data has been retrieved from the debuggee. But that means constant changing.

So I am about to add: "If the innermost array has a length less than <config> then hide the "Len=" header".
Actually even allow hiding for several levels, if overall the element count, and printed text length is below configurable limits.




Similar for line-breaks.

You may normally want each item in an array (or field in struct) to be on its own line. Except if you have "array of integer".

Or maybe, also not if you have "array of array of TPoint. The inner list op points could be  on a single line?
Configurable, but such that a default can have criteria when to go which way.
Code: Text  [Select][+][-]
  1. Test3: array [0..3,0..5] of TPoint;
  2.  
  3. Len=(4, 6):
  4. (((x: 99;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;)),
  5. ((x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;)),
  6. ((x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;)),
  7. ((x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;), (x: 0;y: 0;))
  8. )





So currently I am thinking of the following options to configure how the debugger decides.

The simple form is to just say

- Multi dim array len : Always covers the entire depth.
- Cover N-levels: Covers the outer most N levels (of each individual multi-dim array / i.e. "Test2" restarts counting for "Foo".

And for multiline:
- For the outer N levels display each entry on a new line (level can be array, or structure) (pointer may increase the level, even though it does not add linebreaks)

In both cases there will be similar "rules" to hide the len or go single-line, if the data is "simple enough". Those rules can for example be used to setup defaults.

Array
- Only if more than N levels depth (per multi dim array)
- Only if the array at the current level has a LEN < N
- Only if each element is either "simple" or has less than N simple value (e.g in fields or arrays)
- Only if each value as text is shorter than N chars

Multi line
- Only if within the N innermost levels
- Only if less than N fields for struct
- Only if less than N Len for array (this may not be applied to the innermost array in all cases, since an "array of integer" probably does not need this)
- Only if each element is either "simple" or has less than N simple value (e.g in fields or arrays)
- Only if each value as text is shorter than N chars





DarioGL

  • New member
  • *
  • Posts: 7
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #98 on: September 04, 2024, 02:18:36 pm »
In the image below shows something funny in the watches window (the detail of k[1..6] shows wrong information, starts with 0 in 1 position and the first element does not show properly).

And i use the image to be able to request 2 things: To be able to hide the memory address of pointers and to be able to configure how many decimals are shown.

Regards!

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10293
  • Debugger - SynEdit - and more
    • wiki
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #99 on: September 04, 2024, 02:46:44 pm »
In the image below shows something funny in the watches window (the detail of k[1..6] shows wrong information, starts with 0 in 1 position and the first element does not show properly).
There was a fix (after 3.4 had been released) that might be the issue you have.  If so, this will be in 3.6

Though I need minimum source-code to reproduce, and check if it is the same issue.

Quote
And i use the image to be able to request 2 things: To be able to hide the memory address of pointers and to be able to configure how many decimals are shown.
Both of this should be in 3.99 (and eventually a 4.0 release). They will not be in 3.6.

In 3.99 those settings can be configured as default for all watches, and then modified individually for each watch if needed.

DarioGL

  • New member
  • *
  • Posts: 7
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #100 on: September 04, 2024, 03:33:53 pm »
In the image below shows something funny in the watches window (the detail of k[1..6] shows wrong information, starts with 0 in 1 position and the first element does not show properly).
There was a fix (after 3.4 had been released) that might be the issue you have.  If so, this will be in 3.6

Though I need minimum source-code to reproduce, and check if it is the same issue.

Quote
And i use the image to be able to request 2 things: To be able to hide the memory address of pointers and to be able to configure how many decimals are shown.
Both of this should be in 3.99 (and eventually a 4.0 release). They will not be in 3.6.

In 3.99 those settings can be configured as default for all watches, and then modified individually for each watch if needed.

This is great news, thank you so much for your answer.

Regarding the code, can be a bit hard to extract, i can share the structs we use thou:

Code: Pascal  [Select][+][-]
  1. const
  2.       maxfuen=300000;   {861} {16383}
  3.  
  4. type
  5.      Base=packed record  // packed so we can understand c++: struct __attribute__ ((__packed__)) fuen
  6.           fig        : longint;  {1= , 2=Arc , 3=Line , 4= , 5= , 6= , 7= ini poli , 8=, 9= , 10= punto }
  7.           b1         : boolean;
  8.           nOrd       : longint;
  9.           k          : array[1..6]of double;
  10.           ba1,bb1,bc1: boolean;
  11.           colel      : longint;
  12.      end;
  13.  
  14.      basep=^base;
  15.      tbase=array[0..maxfuen] of basep;
  16.      pbase=^tbase;
  17.  
  18. var
  19.     fuen:pbase;
  20.  
  21.  
  22.  

the ^129 in the image is a position of the fuen variable.

Thanks again!


DarioGL

  • New member
  • *
  • Posts: 7
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #102 on: September 05, 2024, 09:58:55 am »
Thanks, yes I am pretty certain it is the recently fixed issue. https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/41073
Patches for 3.5
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/c462f7256eb55c8c54853a2a3e57ce633c088432
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/eaa2c85a358ea8a60d1b94820d46159c4eb85707

Great! Thanks a lot for your help. Now, im sorry for the n00b question, but... is there a way to get the 3.5 as of now, even if its not released? Or to apply the patch over the version 3.4 and rebuild? Just a link with minimum explanations should be enough. Thanks!

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10293
  • Debugger - SynEdit - and more
    • wiki
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #103 on: September 05, 2024, 10:25:04 am »
The easiest way to install any branch from git is FpcUpDeluxe.

To just apply the changes.
(On linux files are usually write protected, and you need to be root to edit them, but then can continue with your user account)

Gitlab can show you the commits (must be done for each) as diff/patch
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/c462f7256eb55c8c54853a2a3e57ce633c088432.diff
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/c462f7256eb55c8c54853a2a3e57ce633c088432.patch
Either of them can be applied using the "patch" utility (part of linux / on Win part of fpc)

Given that there are only 2 lines of code changed, you can just edit the files by hand.  Open the file in an editor, change the 2 lines.

THen in the IDE, menu Tools, Build Lazarus, and restart.

DarioGL

  • New member
  • *
  • Posts: 7
Re: Poll: Watches and DisplayFormat => How do you think data should be displayed
« Reply #104 on: September 16, 2024, 01:22:23 pm »
The easiest way to install any branch from git is FpcUpDeluxe.

To just apply the changes.
(On linux files are usually write protected, and you need to be root to edit them, but then can continue with your user account)

Gitlab can show you the commits (must be done for each) as diff/patch
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/c462f7256eb55c8c54853a2a3e57ce633c088432.diff
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/c462f7256eb55c8c54853a2a3e57ce633c088432.patch
Either of them can be applied using the "patch" utility (part of linux / on Win part of fpc)

Given that there are only 2 lines of code changed, you can just edit the files by hand.  Open the file in an editor, change the 2 lines.

THen in the IDE, menu Tools, Build Lazarus, and restart.

Cried of happiness! thank you so much!

 

TinyPortal © 2005-2018