User forums > Help

No stdlib, custom startup code - GDB doesn't work

(1/4) > >>

I want to develop program with both Windows and DOS HX support and therefore my program should:
1) Support i386
2) Have minimal size
So I decided to disable stdlib and use my custom startup code instead.

--- Code: (asm) ---.intel_syntax noprefix
.globl _start
#if __x86_64__
    .globl Main
    .globl ExitProcess
    .globl _Main
    .globl _ExitProcess@4
    call Main
    #if __x86_64__
        mov ecx, eax
        push eax
    call ExitProcess

--- End code ---
Please note, that I had to rename main to Main to avoid "__main is undefined" error.

But I have problem now. GDB doesn't work. I set breakpoint, press Debug button and breakpoint isn't triggered. What can be wrong?

Ehhh. Problem is most likely caused by "No source file" and it affects normal projects too. I don't know how to solve it, as path to source files doesn't contain spaces or non-ASCII characters.

Only place, where breakpoints work - startup code. It's very strange, because startup file is placed in exactly the same directory, as main project file. But even in this case GDB doesn't work properly - program execution is stopped, but breakpoint isn't triggered in code editor. If I attempt to resume execution - program just crashes.

Both problems are fixed. Problem with breakpoints not triggering is fixed via adding -g to linker settings. I'm not sure, why default Debug config didn't have it. May be because I deleted it, when I was experimenting with compiler/linker settings. Second problem with application crashing when debugging is fixed via adding separate 32bit debugging profile for 32bit applications.

I have Code::Blocks 20.03 64bit IDE. Both 32bit and 64bit versions of MinGW gcc are installed. 32bit and 64bit build targets are configured to use corresponding compilers and corresponding versions of GDB (i.e. two debugger profiles are created). When I debug 64bit target, every attempt to use Disassembly window causes gdborig.exe crash, while everything works properly for 32bit target. What can be reason for this?

And can anybody tell me, if there is some compiler/linker directive to remove unused (i.e. no exported symbols) .edata section from exe file? I already use -ffunction-sections -fdata-sections for compiler and -Wl,--gc-sections for linker and it doesn't help.

some version of gdb have a bug where they crash in assembly window. This is a known bug in gdb and should be fixed in the last versions (i think version 8.1 had the bug, but i am not sure)

--- Quote ---And can anybody tell me, if there is some compiler/linker directive to remove unused (i.e. no exported symbols) .edata section from exe file
--- End quote ---
a forum about compiler would be the better place to ask


[0] Message Index

[#] Next page

Go to full version