RemedyBG»Forums
4 posts
Not hitting breakpoints
Edited by Werner1886 on
I'm struggling to get remedy hit breakpoints in code loaded from a dll. It says "Symbols loaded" (for the dll) in modules but every breakpoint has little question mark next to it, even though I can call any exported function. It works fine with code from other source files.

Dll is compiled with these
1
-DEBUG:FULL -Zi -Od -MP -MTd -LD dll_source.c -Fmdll_source.map


and everything else with:
1
-DEBUG:FULL -Zi -Od -MP


Are there any swtiches i'm missing?
Mārtiņš Možeiko
2203 posts / 1 project
Not hitting breakpoints
-DEBUG:FULL is linker argument, not cl argument.
To make cl.exe pass it to linker, you need to put it after -link argument, like this:
1
cl.exe ...clarguments... -link -DEBUG:FULL


Also
4 posts
Not hitting breakpoints
Oh, thanks for clarifying that, but unfortunately it didn't change anything.
Simon Anciaux
1060 posts
Not hitting breakpoints
As far as I know the flags you use should be enough. Could you provide a reproduction case ?

http://sscce.org/
4 posts
Not hitting breakpoints
Setting any breakpoints in test.c doesn't work for me with something like this :
(0.3.2.2 remedy version)

win32_test.c
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <windows.h>

static int GlobalRunning;

LRESULT
MainCallbak(HWND Window ,UINT Message ,WPARAM WParam ,LPARAM LParam)
{
    LRESULT Result = 0;
    
    switch(Message)
    {
        case WM_DESTROY:
        case WM_QUIT:
        {
            GlobalRunning = 0;
        } break;
        
        default:
        {
            Result = DefWindowProc(Window ,Message ,WParam ,LParam);
        } break;
        
        break;
    }
    
    return (Result);
}

int WINAPI
wWinMain(HINSTANCE Instance,
         HINSTANCE PrevInstance,
         PWSTR CmdLine,
         int CmdShow)
{
    const char WindowClassName[] = "TestWindowClass";
    const char WindowTitle[]     = "Test";
    
    WNDCLASS WindowClass      = {0};
    WindowClass.style = CS_HREDRAW | CS_VREDRAW;
    WindowClass.lpfnWndProc   = MainCallbak;
    WindowClass.hInstance     = Instance;
    WindowClass.lpszClassName = WindowClassName;
    
    RegisterClass(&WindowClass);
    
    HWND WindowHandle = CreateWindowEx(0,                              
                                       WindowClassName,                     
                                       WindowTitle,
                                       WS_OVERLAPPEDWINDOW,            
                                       CW_USEDEFAULT ,CW_USEDEFAULT,
                                       CW_USEDEFAULT ,CW_USEDEFAULT,
                                       0,           
                                       0,       
                                       Instance,
                                       0);
    
    
    // -----------------------------------
    typedef int (*UPDATE_FUNCTION)(void);
    
    HMODULE OtherCode = LoadLibraryA("test.dll");
    UPDATE_FUNCTION ExternalUpdateFunction = (UPDATE_FUNCTION) GetProcAddress(OtherCode ,"SomeUpdateFunction");
    // -----------------------------------
    
    GlobalRunning = 1;
    ShowWindow(WindowHandle ,SW_SHOW);
    
    while(GlobalRunning)
    {
        MSG Message = {0};
        
        while(PeekMessageA(&Message ,0 ,0 ,0 ,PM_REMOVE))
        {
            switch(Message.message)
            {
                case WM_DESTROY:
                case WM_QUIT:
                {
                    GlobalRunning = 0;
                } break;
                
                default:
                {
                    TranslateMessage(&Message);
                    DispatchMessage(&Message);
                } break;
                
            }
            
        }
        
        GlobalRunning = ExternalUpdateFunction();
        
        Sleep(5);
    }
    
    return 0;
}


test.c
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
int
SomeUpdateFunction()
{
    static int SomeCounter = 0;
    
    int BreakHere = 22;
    if(BreakHere >= 20)
    {
        BreakHere++;
    }
    
    return (SomeCounter++ < 200);
}


build.bat
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
@echo off

set CompilerFlags=-Zi -nologo -Od -MP

pushd build\

cl %CompilerFlags% -MTd -LD ..\src\test.c -Fmtest.map -link -DEBUG:FULL -INCREMENTAL:no -EXPORT:SomeUpdateFunction

cl %CompilerFlags% ..\src\win32_test.c -link -INCREMENTAL:no -DEBUG:FULL -out:test.exe user32.lib gdi32.lib

popd
Simon Anciaux
1060 posts
Not hitting breakpoints
The issue is that you're renaming the exe in a similar name than the dll and that causes the two objects to use the same name for the pdb files. So win32_test compilation will overwrite the pdb produced by test.

You can specify a different pdb file name by passing /PDB:filename to the linker. Or produce win32_test.exe and just rename the exe after the compilation (for example adding a rename command in build.bat).
4 posts
Not hitting breakpoints
Yes, thank you!!