Results 1 to 4 of 4

Thread: multithread application debugging

  1. #1

    multithread application debugging

    I have some problems debugging a multithread application with softice.How can i find the program's executed code when sleep or sleepex or wait_semaphore functions are called.

  2. #2
    Which code? The code in the thread? When the thread is created, a pointer to the function comprising the start of the thread is passed to CreateThread (or whatever). Thus, you have the entry point for your thread.

    Your question is a bit vague, but I assume you're asking "How do I know which bit of code is being executed in thread 1 whilst thread 0 is waiting for a semaphore/mutex/section?". There is no simple way to do this, but IMO the best way is to find the call in thread 1 that signals the semaphore/mutex/csection. In other words:

    1. Thread 0 creates thread 1.
    2. Thread 0 sleeps, waiting for the csection to signal.
    3. Thread 1 does stuff.
    4. Thread 1 signals the csection.
    5. Thread 0 wakes up.

    To find what is happening at (3), find (4) and work backwards. This seems the logical way to do it to me, and the way I've done it in the past. Others may be able to suggest a technique/tool that is more efficient.

    CreateThread reference:

    *edit* I lost the ability to type...
    Still here...

  3. #3

    It seems a little bite more complex

    Thanks for your reply and i know that
    HANDLE CreateThread(
    LPSECURITY_ATTRIBUTES lpThreadAttributes, // SD
    SIZE_T dwStackSize, // initial stack size
    LPTHREAD_START_ROUTINE lpStartAddress, // thread function
    LPVOID lpParameter, // thread argument
    DWORD dwCreationFlags, // creation option
    LPDWORD lpThreadId // thread identifier
    lpStartAddress is the thread start function but there are 2 problems:
    1-The program creates too many threads at the startup and i can't trace from this point.
    2-When sleep function called It doesn't mean the execution of thread starts from the beginning,and i want to find first instruction from program which executed.
    This is my situation
    The program calls SendMessageA,break on PeekMessageA and i land on one of programs dll,then it goes in a loop and calls kernel32.sleep and calls some bad stuff!

  4. #4
    Administrator dELTA's Avatar
    Join Date
    Oct 2000
    Ring -1
    Blog Entries
    You are still being quite vague, but as far as I can see you want to catch a thread immediately when it returns from a sleep() call? Simply put a breakpoint on the instruction after the sleep() call in the program code. This would be the first instruction of the program's own code being executed after the sleep (while the first instruction in the thread would of course be somewhere inside the sleep API code, but I can't imagine why you would need that anyway).

Similar Threads

  1. Replies: 10
    Last Post: February 1st, 2013, 09:13
  2. So... what is THIS application now?
    By Aimless in forum Off Topic
    Replies: 2
    Last Post: August 29th, 2011, 09:50
  3. Problem debugging DirectX application
    By LOPAN in forum The Newbie Forum
    Replies: 4
    Last Post: March 1st, 2010, 19:16
  4. Replies: 3
    Last Post: December 4th, 2008, 01:57
  5. 16 bit dos application
    By zmintu in forum The Newbie Forum
    Replies: 6
    Last Post: March 22nd, 2008, 18:10


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts