C backend current limitations while debugging

Everything else that doesn't fall into one of the other PB categories.
User avatar
luis
Addict
Addict
Posts: 3876
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

C backend current limitations while debugging

Post by luis »

If I'm not mistaken, this is the current state of affairs.
Posting here for future reference / checks.
Enable debugger and purifier to test it.

Code: Select all

PurifierGranularity(1,1,1,1)

; Array out of bounds 
; ASM OK
; C not working / still not implemented (see https://www.purebasic.fr/english/viewtopic.php?t=81031 )
Dim a(10)
For k = 0 To 11
 a(k) = 123 
Next

; Global variable overflow 
; ASM OK
; C not supported (see https://www.purebasic.fr/english/viewtopic.php?p=573179 )
Global var.b
PokeI(@var, 123456) 

; Local variable overflow  
; ASM OK
; C not supported (see https://www.purebasic.fr/english/viewtopic.php?p=573179 )
Procedure foo()
 Protected var.b
 PokeI(@var, 123456) 
EndProcedure : foo()

; Allocated memory area overflow 
; ASM OK
; C OK
*p = AllocateMemory(16)
For k = 0 To 16
 PokeB(*p + k, $80) 
Next

; String memory block overflow
; ASM OK
; C OK
a$ = "12345678"
PokeB(@a$ + SizeOf(Character) * 9, $80)

EDIT: "Array out of bounds" fixed
viewtopic.php?t=81031
Last edited by luis on Sat Apr 01, 2023 7:34 pm, edited 1 time in total.
"Have you tried turning it off and on again ?"
A little PureBasic review
juergenkulow
Enthusiast
Enthusiast
Posts: 544
Joined: Wed Sep 25, 2019 10:18 am

Re: C backend current limitations while debugging

Post by juergenkulow »

Code: Select all

//purebasic.c  compared With purebasic.asm 
// a(k) = 123 
DBG_Check(7);
((integer*)a_a.a)[(integer)v_k]=123;

; a(k) = 123 
  MOV    rdi,7
  CALL   DBL
  MOV    r15,qword [v_k]
  MOV    rax,r15
  MOV    rdx,qword [a_a]
  MOV    rdx,[rdx-16]
  CALL  _DBG_A
  MOV    rbp,qword [a_a]
  SAL    r15,3
  MOV    qword [rbp+r15],123
  
  
// PokeI(@var, 123456) 
DBG_Check(14);
quad p0=(quad)((integer)(&v_var));
PB_PokeI_DEBUG(p0,123456LL);
integer rr1=PB_PokeI(p0,123456LL);
PB_PURIFIER_Check(0,0,0)         ;

; PokeI(@var, 123456) 
  MOV    rdi,14
  CALL   DBL
  PUSH   qword 123456
  LEA    rax,[v_var]
  MOV    rax,rax
  PUSH   rax
  POP    rdi
  POP    rsi
  MOV    r10,PB_PokeI_DEBUG
  MOV    r11,0
  CALL  _DBG_CallDebug
  CALL   PB_PokeI
  XOr    rdx,rdx
  XOr    rsi,rsi
  MOV    rdi,qword PMG
  CALL   PB_PURIFIER_Check
  
  
// Protected var.b;
// PokeI(@var, 123456) 
DBG_Check(21);
quad p1=(quad)((integer)(&v_var));
PB_PokeI_DEBUG(p1,123456LL);
integer rr2=PB_PokeI(p1,123456LL);
PB_PURIFIER_Check(0,0,0)         ;
  
  ; PokeI(@var, 123456) 
  MOV    rdi,21
  CALL   DBL
  PUSH   qword 123456
  LEA    rax,[rsp+48]
  MOV    rax,rax
  PUSH   rax
  POP    rdi
  POP    rsi
  MOV    r10,PB_PokeI_DEBUG
  MOV    r11,0
  CALL  _DBG_CallDebug
  CALL   PB_PokeI
  MOV    rdx,rsp
  MOV    rsi,qword PM_0
  MOV    rdi,qword PMG
  CALL   PB_PURIFIER_Check
Post Reply