Debug register

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Debug register

Post by mdp »

To see the content of a register is pretty easy

Code: Select all

Global deb

; ... my ASM code ...

!MOV  dword [v_deb],ebx
Debug deb
But still a little too tricky :)

Is it possible to have a direct something like

Code: Select all

Debug eax
Thanks
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

See the OnError lib:

Code: Select all

GetErrorRegister(#Register)
or Menu:Debugger-->Assembly

:wink:
--Kale

Image
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Tried the assembly debugger combined with a breakpoint?
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

yes, the debugger support assembly register display so it should work.
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Post by mdp »

@kale

Well,

Code: Select all

!MOV  eax,123
Debug GetErrorRegister( #PB_OnError_EAX )
returns 0...
The problem is that also

Code: Select all

!MOV  eax,123
a=GetErrorRegister( #PB_OnError_EAX )
Debug a
returns 0 :!: :?: Maybe the command works only in case of error? Sorry, I'm not used to the OnError commands.

@Trond, @Fred
the Debug command, compared to the assembly debugger window, has the feature of the flow of data - you can see all the values at the same time. Since they can be thousands, it's more comfortable than writing them down step by step.
If I may add (your prompt responses anticipated an edit-addendum for my post), the Debug command does not preserve the register situation when it is called, so - in the way I showed at the top - it 'breaks' the rest of the code.
So, I would also like to suggest that 'Debug' would restore the eax,ebx etc. contents after it is called.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

mdp wrote: The problem is that also

Code: Select all

!MOV  eax,123
a=GetErrorRegister( #PB_OnError_EAX )
Debug a
returns 0 :!: :?: Maybe the command works only in case of error? Sorry, I'm not used to the OnError commands.
exactly, if an error is catched, a register-snapshot is taken.
SPAMINATOR NR.1
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

About 'Debug' preserving all the registers, it's a good idea, we will add it.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Fred wrote:About 'Debug' preserving all the registers, it's a good idea, we will add it.
Can we have this too please?

viewtopic.php?t=18478 :twisted:
--Kale

Image
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Can you use something like this?

Code: Select all

!mov  eax, 5
!call deax
!call deax
!add  eax, eax
!call deax



End
!deax:
!push eax
!mov [v_asmdebug_32b], eax
Debug asmdebug_32b
!pop eax
!ret
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Also it would be nice if Debug didn't clear GetLastError_().
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

In the v4, it doesn't use any API anymore, so it shouldn't clear the GetLastError_().
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Another suggestion for the debugger: If debugging a string, do a new line for CRLF.
mdp
Enthusiast
Enthusiast
Posts: 115
Joined: Mon Apr 18, 2005 8:28 pm

Post by mdp »

It seems that the answer to my post could in PB4 be the following:

Code: Select all

Macro Deb_EBX
   MOV  dword [v_debvar],ebx
   PUSH eax : PUSH ebx : PUSH ecx : PUSH edx : PUSH ebp  
   Debug debvar
   POP  ebp : POP edx : POP ecx : POP ebx : POP eax
EndMacro

;e.g.
MOV   ebx,345
Deb_EBX
INC   ebx
Deb_EBX
Could, because I don't know exactly which registers to preserve ;-)
Some lines in the forthcoming documentation will be appreciated (if not the specification of the registers used by every pb command)
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

About 'Debug' preserving all the registers, it's a good idea, we will add it.
Did you forget it or just not high enough prioritized amongst all the other features?

Code: Select all

Global _regout
Macro regout(reg)
  !push eax
  !push ecx
  !push edx
  !mov  edx, reg
  !mov  [v__regout], edx
  Debug _regout
  !pop  edx
  !pop  ecx
  !pop  eax
EndMacro

!mov eax, 464
regout(eax)
regout(eax)
!add eax, eax
!mov ebx, eax
regout(ebx)
regout(ebx)
For all 32-bit general purpose registers:
eax, ebx, ecx, edx, esi, edi, ebp and esp.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Using pushad/popad is probably a bit faster to write when you want to preserve all the registers ;).
Post Reply