This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

How construct stack frame manually


Hi, everyone
    It's me again. I am writing a toy os and come across a annoying
problem with gdb or something else. The os boots from 16bit real mode
assembly codes and jumps to C codes which are also executed in real
mode currently. The problem is that if the control enters the C
function and "backtrace" command is issued, I get message of
"backtrace stopped: no enough available registers or memory to unwind
further" and only the innermost frame(frame 0) is displayed. I guess
this is related with stack frame. The following is the codes related
with stack.
    /*
     * The 16bit real mode assembly codes
     * before call C function
     */
    xorw %bp, %bp
    movw %0x9000, %ss
    movw %0xfffc, %sp
    call main

    /* 16bit C codes */
    void  main()
    {
         int i = 0;
         setup(i);
    }

    int setup(int n)
    {
        int count = i;
        count <<= 1;
        return count;
    }
    Take the codes above for example. If the control have entered the
setup and "backtrace" is issued, I'd see the message below:

    # 0 main(): main.c: 3
    Backtrace stopped: No enough available registers or memory to unwind further

    And if "print i" command is issued, I'd see the message blew:

    can't compute CFA for this frame

    As a result, I can't exam executing stats using print or backtrace
commands. It's a annoying problem for me to write a large amount C
codes like this toy os.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]