Recent

Author Topic: FpDebug, small x86 disassembler bug  (Read 627 times)

mika

  • Jr. Member
  • **
  • Posts: 77
FpDebug, small x86 disassembler bug
« on: November 30, 2022, 07:18:00 pm »
Code: Pascal  [Select][+][-]
  1. program testdbg18;
  2. {$apptype console}
  3. {$mode objfpc}{$h+}
  4.  
  5. uses FpDbgDisasX86, FpDbgClasses, FpDbgUtil;
  6.  
  7. const  testCode : shortstring = #$a3#$1a#$00#$00#$00; {mov [$0000001a],eax}
  8.  
  9. var    p : pointer  ;
  10.        codeBytes, asmInstr : string;
  11.        pr : TDbgProcess;
  12.        de : TX86AsmDecoder;
  13.  
  14. begin
  15.      pr:= TDbgProcess.create(dm32);
  16.      de := TX86AsmDecoder.create( pr );
  17.      p:=@testCode[1];
  18.      de.Disassemble(p, codeBytes, asmInstr );
  19.      writeln;
  20.      writeln( codeBytes:20,'    ', asmInstr);
  21.      readln;
  22. end.

output
          A31A000000    mov dword ptr [$0000001A],al

output should be
          A31A000000    mov [$0000001A],eax

file fpdbgdisasx86.pas

Code: Pascal  [Select][+][-]
  1.       $A3: begin
  2.         SetOpcode(OPmov);
  3.         AddOv;
  4.         AddReg(regGeneral, os8, REG_A);
  5.  

fix

Code: Pascal  [Select][+][-]
  1.       $A3: begin
  2.         SetOpcode(OPmov);
  3.         AddOv;
  4.         AddReg(regGeneral, OperandSize, REG_A);
  5.  
« Last Edit: November 30, 2022, 07:25:31 pm by mika »

PascalDragon

  • Hero Member
  • *****
  • Posts: 4870
  • Compiler Developer
Re: FpDebug, small x86 disassembler bug
« Reply #1 on: November 30, 2022, 10:19:21 pm »
Please report on the bug tracker.

mika

  • Jr. Member
  • **
  • Posts: 77
Re: FpDebug, small x86 disassembler bug
« Reply #2 on: November 30, 2022, 11:47:14 pm »
Please report on the bug tracker.
Not registered there. Not going to report.
Your suggestion i will take as a hint to not report bugs in forum.
But if some one is going to investigate this, then look at lds,les,.. instructions with operand and address size modifiers.
« Last Edit: November 30, 2022, 11:55:59 pm by mika »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8605
  • Debugger - SynEdit - and more
    • wiki
Re: FpDebug, small x86 disassembler bug
« Reply #3 on: December 01, 2022, 11:33:10 am »
Please report on the bug tracker.
Not registered there. Not going to report.
Your suggestion i will take as a hint to not report bugs in forum.
But if some one is going to investigate this, then look at lds,les,.. instructions with operand and address size modifiers.

You can mention bugs here. Sometimes they will be spotted. And then it's a question if they will be remembered.
For now, I noted this one. Hopefully it wont fall through the cracks....

The bug tracker makes sure it will be remembered.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8605
  • Debugger - SynEdit - and more
    • wiki
Re: FpDebug, small x86 disassembler bug
« Reply #4 on: December 02, 2022, 03:19:58 am »
Fixed

Bogen85

  • Sr. Member
  • ****
  • Posts: 369
Re: FpDebug, small x86 disassembler bug
« Reply #5 on: December 02, 2022, 09:49:51 pm »
Fixed

Fixed, as in, fixed in the source code? If so, what is the issue tracker number for this?

I did not know this existed for FPC (disassembly functions), though due to this Topic I now see that it is the Lazarus sources.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8605
  • Debugger - SynEdit - and more
    • wiki
Re: FpDebug, small x86 disassembler bug
« Reply #6 on: December 02, 2022, 10:07:12 pm »
Fixed
Fixed, as in, fixed in the source code? If so, what is the issue tracker number for this?
The commit is 4c879cc73cc403526099b3eadde64c03c9a82f31

There is no bug tracker id, since - as you may have read - the reporter did not want to create an account to the tracker.

Which means, it is lucky I got time now. Otherwise it might easily have been forgotten.
- "Time" just doesn't mean the 30 seconds to change one word, and commit it.
- "Time" means everything from checking that this is currently wrong, and that the suggest disassemble is the correct one. We are all humans, the reporter could have mis-reported too. Then checking that the changed line returns the new desired value. Checking desired, current, and fixed results for other op-sizes (which would be expected to exist). So "Time" amounts. And had I been in the middle of something else, I might not have interrupted that (even if that be a project taking a few month).

Quote
I did not know this existed for FPC (disassembly functions), though due to this Topic I now see that it is the Lazarus sources.

They exist in Lazarus => FpDebug. Since the debugger should be able to display disassembly.

Bogen85

  • Sr. Member
  • ****
  • Posts: 369
Re: FpDebug, small x86 disassembler bug
« Reply #7 on: December 02, 2022, 10:19:58 pm »
The commit is 4c879cc73cc403526099b3eadde64c03c9a82f31

There is no bug tracker id, since - as you may have read - the reporter did not want to create an account to the tracker.

Which means, it is lucky I got time now. Otherwise it might easily have been forgotten.

Got it!

I understand.

They exist in Lazarus => FpDebug. Since the debugger should be able to display disassembly.

Thanks!

Per the code in the reporter's example this will be useful to me in non-gui programs.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 8605
  • Debugger - SynEdit - and more
    • wiki
Re: FpDebug, small x86 disassembler bug
« Reply #8 on: December 03, 2022, 03:47:43 pm »
Btw, if anyone has spare time....

But if some one is going to investigate this, then look at lds,les,.. instructions with operand and address size modifiers.

This indicates that there may or may not be other similar cases.

But I don't have time to verify this currently.

 

TinyPortal © 2005-2018