Author Topic: Complementary macros for debugging  (Read 3386 times)

HSE

  • Member
  • *****
  • Posts: 2499
  • AMD 7-32 / i3 10-64
Complementary macros for debugging
« on: December 13, 2020, 04:18:48 AM »
Hi all!

Here some macros that help me to follow execution of complex objects.

At program beginning, previous to object making:
Code: [Select]
carteleria = 0
carteleriat = 0
include TitulosMacs.asm
When using several libraries, I 'm making carteleria = 1000 in one library, carteleria = 2000 in other library, and so on.

Inside objects methods:
Code: [Select]
Method SerieGraph.Clear , uses esi
DbgMtit   <----
SetObject esi
OCall [esi].Puntos::LinkedList.Clear
DbgMsal   <----
MethodEnd

Then at runtime you obtain indented text, with some values to keep execution track :
Code: [Select]
    + OA_ExperimentalTest._Init  pSelf = 00186600  esi = 00000000  dir = 0043B976
       + OA_ExperimentalUnit._Init  pSelf = 001866B0  esi = 00186600  dir = 00415AA1
          + OA_IntgSim._Init  pSelf = 00191658  esi = 001866B0  dir = 00413EF5
          - OA_IntgSim._Init  pSelf = 00191658  esi = 00191658  dir = 00414118
       - OA_ExperimentalUnit._Init  pSelf = 001866B0  esi = 001866B0  dir = 0043B447
    - OA_ExperimentalTest._Init  pSelf = 00186600  esi = 00186600  dir = 0043BBE1
pSelf is the object called, esi is the callee object (usually), and dir is memory position of method that you can see with Olly.

Use in place you want begin /end to follow:
Code: [Select]
mov DbgGlobalActivated,1 (or 0)
Also you can use words and colors to follow execution (TODO and TODOLOG in this case).

Regards. HSE
« Last Edit: December 15, 2020, 07:17:10 AM by HSE »
Equations in Assembly: SmplMath

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: Complementary macros for debugging
« Reply #1 on: December 13, 2020, 05:25:04 PM »
Hi HSE
Thanks for sharing  :thumbsup:

Regards, Biterider

HSE

  • Member
  • *****
  • Posts: 2499
  • AMD 7-32 / i3 10-64
Re: Complementary macros for debugging
« Reply #2 on: December 15, 2020, 07:10:49 AM »
Hi Biterider!

Perhaps could be interesting something like StrMake procedure in the library.

Regards. HSE
Equations in Assembly: SmplMath

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: Complementary macros for debugging
« Reply #3 on: December 16, 2020, 05:38:46 AM »
Hi HSE
Do you have some documentation of this procedure?
Is it something like https://opensource.apple.com/source/apache_mod_php/apache_mod_php-17/php/ext/mysql/libmysql/strmake.c.auto.html? :rolleyes:
Biterider

HSE

  • Member
  • *****
  • Posts: 2499
  • AMD 7-32 / i3 10-64
Re: Complementary macros for debugging
« Reply #4 on: December 16, 2020, 06:51:07 AM »
Hi Biterider!

I think is based in the procedure to draw lines in DebugCenter or some other function, not sure, and I just invented a name (not very creative indeed  :biggrin:).

HSE

PD. not DebugCenter  :cool:
Equations in Assembly: SmplMath

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: Complementary macros for debugging
« Reply #5 on: December 16, 2020, 08:19:32 AM »
Hi HSE
Sorry i misunderstood you
In the current version of ObjMem there is a procedure called StrRepChrA and StrRepChrW that do what you want.
I'm not sure if it's in the C.1.0 distribution, but it sure is in the GitHub repo.  :biggrin:

A variation on how to fill a pre-allocated buffer could be a new procedure called FillRepChar. :icon_idea:

Biterider

HSE

  • Member
  • *****
  • Posts: 2499
  • AMD 7-32 / i3 10-64
Re: Complementary macros for debugging
« Reply #6 on: December 16, 2020, 08:42:05 AM »
Hi Biterider!

In the current version of ObjMem, there is a proc called StrRepChrA and StrRepChrW, which do exactly what you want.

I found the procs, not the same (requires allocation and deallocation) but they can to make the work. :thumbsup:

I don't wanted, just thinking in thousands of ObjAsm users  :biggrin:

Regards. HSE
Equations in Assembly: SmplMath

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: Complementary macros for debugging
« Reply #7 on: December 16, 2020, 08:55:38 AM »
Hi HSE
A quick fix solution may be using the MemFillB procedure, but you have to set the zero terminating char yourself.
Unfortunately, there is no MemFillW proc yet, but it can be added easily.

With this building block we can create a new proc like:

Code: [Select]
StrFillA proc pBuffer:POINTER, Char:CHRA, dRep:DWORD
  invoke MemFillB, pBuffer, dRep, Chr
  mov eax, pBuffer
  add eax, dRep
  mov [eax], 0
  ret
StrFillA endp

Biterider

HSE

  • Member
  • *****
  • Posts: 2499
  • AMD 7-32 / i3 10-64
Re: Complementary macros for debugging
« Reply #8 on: December 16, 2020, 09:14:23 AM »
That is  :thumbsup: :thumbsup: :thumbsup:
Equations in Assembly: SmplMath

Biterider

  • Moderator
  • Member
  • *****
  • Posts: 1083
  • ObjAsm Developer
    • ObjAsm
Re: Complementary macros for debugging
« Reply #9 on: December 17, 2020, 06:38:05 AM »
Good News  :cool:
I added MemFillW, StrFillChrA/W in 32 and 64 bit to the ObjMem library.
The code is available on the GitHub repo.


Biterider

HSE

  • Member
  • *****
  • Posts: 2499
  • AMD 7-32 / i3 10-64
Re: Complementary macros for debugging
« Reply #10 on: December 17, 2020, 09:50:13 AM »
Fantastic  :thumbsup:
Equations in Assembly: SmplMath