Recent

Author Topic: How to change the display to hexadecimal ?  (Read 7742 times)

440bx

  • Hero Member
  • *****
  • Posts: 3946
How to change the display to hexadecimal ?
« on: August 11, 2018, 04:58:56 am »
Hello,

One very nice feature when debugging is that you can place the mouse over a data structure and after a second (or so) a window showing the values of all the fields in the data structure pops up.

The "problem" is that the values of integer fields (byte, word, dword, etc) are shown in decimal and I'd like to have them shown in hexadecimal.

Is there a way to configure that popup to show the values in hex instead of decimal ?

Thanks.
(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: 9794
  • Debugger - SynEdit - and more
    • wiki
Re: How to change the display to hexadecimal ?
« Reply #1 on: August 11, 2018, 11:15:45 am »
Only in the watches window. There you can use the properties of each watched value.

The debug hint does not have that.

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: How to change the display to hexadecimal ?
« Reply #2 on: August 11, 2018, 01:14:18 pm »
Only in the watches window. There you can use the properties of each watched value.

The debug hint does not have that.
Thank you Martin.   I'll just have to get used to decimals.  My grocery store is like that too, I asked them to put the prices in hex but, they didn't go for it.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Ondrej Pokorny

  • Full Member
  • ***
  • Posts: 220
Re: How to change the display to hexadecimal ?
« Reply #3 on: August 13, 2018, 10:16:26 am »
The debug hint does not have that.

It has. See how TDateTime is implemented: unit "ide\debugmanager.pas" in constructor TDebugManager.Create(TheOwner: TComponent);

RegisterValueFormatter(skSimple, 'TDate', @DBGDateTimeFormatter);

- you can install your own value formatter for every type in your IDE extension package

ASerge

  • Hero Member
  • *****
  • Posts: 2223
Re: How to change the display to hexadecimal ?
« Reply #4 on: August 13, 2018, 07:48:16 pm »
Here's a simple package implementing what Ondrej Pokorny has pointed out.

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: How to change the display to hexadecimal ?
« Reply #5 on: August 13, 2018, 08:04:09 pm »
Excellent! I've been missing this all the time. Could you write a bugtracker feature request to get it added to the IDE?

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: How to change the display to hexadecimal ?
« Reply #6 on: August 13, 2018, 09:00:34 pm »
Excellent! I've been missing this all the time. Could you write a bugtracker feature request to get it added to the IDE?

I second wp's opinion, that is excellent indeed.    Thank you Serge.

Here is to show that I am still a clueless noobie.  I installed the package (lazarus recompiled successfully), checked in the "install/uninstall package" and it is in the list of installed packages.  In spite of that, I still get the values in decimal. 

What did I miss to have the values in hex ?  Do I need to add a "uses <something>" to my code ?

Thanks.



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

wp

  • Hero Member
  • *****
  • Posts: 11858
Re: How to change the display to hexadecimal ?
« Reply #7 on: August 13, 2018, 09:22:11 pm »
Did you click "Save and rebuild IDE"? Or, in the dialog in which you loaded the package you must click "Use" > "Install", not only "Compile".

This will rebuild the IDE with the new package included. It will take a while... When finished Lazarus will restart.

Then you set a breakpoint in your program, compile and run it. When the program stops at the breakpoint you hover the mouse above a numeric variable, and the popup will show you the decimal and hex value of the variable.

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: How to change the display to hexadecimal ?
« Reply #8 on: August 13, 2018, 09:30:50 pm »
Then you set a breakpoint in your program, compile and run it. When the program stops at the breakpoint you hover the mouse above a numeric variable, and the popup will show you the decimal and hex value of the variable.

Thanks wp.  It works exactly as you described it.  The problem is, I am/was hovering over a record with a bunch of fields  (that's the variable I'm particularly interested in seeing in hex) and, in records, it still shows the values in decimal.  I suppose the package doesn't support record fields.



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

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: How to change the display to hexadecimal ?
« Reply #9 on: November 22, 2022, 05:39:08 pm »
Hello,

I installed @ASerge's rather handy ShowIntAsHex in Lazarus trunk v2.3.0 revision main-2_3_2330, Win64 version.  The FPC version is also the trunk version of 3.3.1.

After installing ShowIntAsHex (and using GDB), either GDB or Lazarus causes an access violation which forces terminating the debugging session.  Note: I don't know if the problem would occur using FpDebug.

My question is: is ShowIntAsHex not compatible with the current trunk version of Lazarus and FPC ?

Also: is anyone successfully using ShowIntAsHex with the current trunk versions of FPC and Lazarus ?

Thank you for your help.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: How to change the display to hexadecimal ?
« Reply #10 on: November 22, 2022, 05:59:25 pm »
Silly.
We have <simple real>.ToHexString for that. (two overloads, I wrote them)
The Lazarus IDE maintainers should take note.
« Last Edit: November 22, 2022, 06:05:38 pm by Thaddy »
Specialize a type, not a var.

440bx

  • Hero Member
  • *****
  • Posts: 3946
Re: How to change the display to hexadecimal ?
« Reply #11 on: November 22, 2022, 06:01:18 pm »
Silly.
We have <simple real>ToHexString for that.
ShowIntAsHex causes the _debugger_ to show the value in hex in addition to decimal.   Didn't you read the post ?
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: How to change the display to hexadecimal ?
« Reply #12 on: November 22, 2022, 06:02:43 pm »
Read my edit. Posts crossed.
Specialize a type, not a var.

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: How to change the display to hexadecimal ?
« Reply #13 on: November 22, 2022, 06:04:54 pm »
It can simply be a case of IDE maintainers are not aware of that. It should be a very easy fix.
« Last Edit: November 22, 2022, 06:07:45 pm by Thaddy »
Specialize a type, not a var.

 

TinyPortal © 2005-2018