public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* How construct stack frame manually
@ 2011-10-31  8:40 zhihua che
  0 siblings, 0 replies; only message in thread
From: zhihua che @ 2011-10-31  8:40 UTC (permalink / raw)
  To: gdb

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-10-30 19:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-31  8:40 How construct stack frame manually zhihua che

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).