flat assembler
Message board for the users of flat assembler.

Index > Windows > How to debug procedures?

Author
Thread Post new topic Reply to topic
veach1



Joined: 16 Jul 2004
Posts: 165
veach1
Hello!
I use OllyDBG and have two questions:
1) I`m trying to sort Items in ListView, using SendMessage function with lParam = pointer to the comparison procedure (as in Iczelion`s tutorial).
Everything seems ok, but! How to debug that procedure?

Code:
        ...
start:
        ...
wmNOTIFY:
        ...
        COLUMNCLICK_0:
        ...
        invoke SendMessage, [lvH], LVM_SORTITEMS, 0, lv_cmp
        call lv_param_update
        ...
.end start
;-----------------------------------------------------------------
proc lv_cmp, lParam1, lParam2, lParamSort
enter
...
return
endp
;-----------------------------------------------------------------
proc lv_param_update
enter
...
return
endp
    


2) More common question - how to debug procedures created with proc macros?

Maybe somebody have some other solutions on procedures implimentation?

_________________
dream of mind creates a monster
Post 17 Aug 2005, 14:48
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1607
Location: Ukraine
shoorick
hi!
2. i'm usualy use this:
Code:
macro deb
{       
if DEBUG_VERSION
    local .nodeb
    pusha
        invoke IsDebuggerPresent
        test eax,eax
        popa
        jz .nodeb
        int3
.nodeb:
end if
}
    

then place "deb" where you want
regards1
Post 17 Aug 2005, 15:37
View user's profile Send private message Visit poster's website Reply with quote
veach1



Joined: 16 Jul 2004
Posts: 165
veach1
How and where should I define DEBUG_VERSION?
Post 18 Aug 2005, 06:49
View user's profile Send private message Reply with quote
veach1



Joined: 16 Jul 2004
Posts: 165
veach1
hmm... solution for 2) ?
Defining procs before '.end start' causes them to be located in the .code section and OLLY trace there as normal, definig procs after '.end start' causes them to be located in .idata section, OLLY can trace there but no analysing allowed and breakpoints can be set only as data breakpoints.

First question remains open...
Post 18 Aug 2005, 07:37
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1607
Location: Ukraine
shoorick
1. DEBUG_VERSION > sorry, just pasted from my source - it is definition i'm using. you can refuse from it or just define it at the start eg DEBUG_VERSION equ 1 (or 0) to avoid appearing of int3 in ready source (and also used by me to some other conditional compilation for debug versions)

2.not sure i understand clear about before and after: you asked about debugging procedure created with proc macro. there is no much difference between proc procedure and usual procedure, the only thing is implicit creating and removing stack frame in the first time by macros.

Code:
;===========================
proc GetFileSizeName lpFileName ; ZF=1 if fail
;----------------------------------
    local wfd:WIN32_FIND_DATA
;----------------------------------
    deb ; <=== here run will stop and 
        ;      started debugging
        ;      of this procedure   
    lea ecx,[wfd]
    invoke FindFirstFile,[lpFileName],ecx
    cmp eax,INVALID_HANDLE_VALUE
    


provided macro checks if current application runs under debugger, and if yes - executing int3 command to stop executing and start debugging. place line with single "deb" at the start of procedure code and run application from Olly - and it will stop there. of course, you can place this line in other place where you are interesting.

you can skip all of this and just place int3, but if you occasionally start it directly to run, int3 closes application if no debugger registered in the system or will pop it. if it is because you just forgot to remove int3 - it is not good, thus i'm using such macro: int3 will placed into code only for debug versions, not for release, and will executed only when run under debugger.

is this complete? Wink
Post 18 Aug 2005, 08:09
View user's profile Send private message Visit poster's website Reply with quote
veach1



Joined: 16 Jul 2004
Posts: 165
veach1
working! Very Happy
Thank you!
Post 18 Aug 2005, 08:17
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1607
Location: Ukraine
shoorick
also it is possible to use simbolic debugging, but then you have to create object and then link it to the exe with creating maps etc., but i'm not familiar with this.

about question first: place deb or int3 into any or both lv_cmp & lv_param_update after 'enter' and you should catch all resorting.

regards!
Post 18 Aug 2005, 08:56
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1607
Location: Ukraine
shoorick
oh! i was late - server did not work 30 min Smile
Post 18 Aug 2005, 08:58
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.