The MASM Forum

Projects => ObjAsm => Topic started by: HSE on December 13, 2020, 04:18:48 AM

Title: Complementary macros for debugging
Post by: HSE 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:
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: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 :    + 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:mov DbgGlobalActivated,1 (or 0)

Also you can use words and colors to follow execution (TODO and TODOLOG in this case).

Regards. HSE
Title: Re: Complementary macros for debugging
Post by: Biterider on December 13, 2020, 05:25:04 PM
Hi HSE
Thanks for sharing  :thumbsup:

Regards, Biterider
Title: Re: Complementary macros for debugging
Post by: HSE on December 15, 2020, 07:10:49 AM
Hi Biterider!

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

Regards. HSE
Title: Re: Complementary macros for debugging
Post by: Biterider 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 (https://opensource.apple.com/source/apache_mod_php/apache_mod_php-17/php/ext/mysql/libmysql/strmake.c.auto.html)? :rolleyes:
Biterider
Title: Re: Complementary macros for debugging
Post by: HSE 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:
Title: Re: Complementary macros for debugging
Post by: Biterider 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
Title: Re: Complementary macros for debugging
Post by: HSE on December 16, 2020, 08:42:05 AM
Hi Biterider!

Quote from: Biterider on December 16, 2020, 08:19:32 AM
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
Title: Re: Complementary macros for debugging
Post by: Biterider 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:


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
Title: Re: Complementary macros for debugging
Post by: HSE on December 16, 2020, 09:14:23 AM
That is  :thumbsup: :thumbsup: :thumbsup:
Title: Re: Complementary macros for debugging
Post by: Biterider 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
Title: Re: Complementary macros for debugging
Post by: HSE on December 17, 2020, 09:50:13 AM
Fantastic  :thumbsup: