From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29827 invoked by alias); 30 Oct 2011 19:06:03 -0000 Received: (qmail 29813 invoked by uid 22791); 30 Oct 2011 19:06:01 -0000 X-SWARE-Spam-Status: No, hits=1.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_OV X-Spam-Check-By: sourceware.org Received: from mail-gx0-f169.google.com (HELO mail-gx0-f169.google.com) (209.85.161.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 30 Oct 2011 19:05:47 +0000 Received: by ggnh4 with SMTP id h4so6065846ggn.0 for ; Sun, 30 Oct 2011 12:05:47 -0700 (PDT) MIME-Version: 1.0 Received: by 10.68.56.165 with SMTP id b5mr17861152pbq.86.1320001546915; Sun, 30 Oct 2011 12:05:46 -0700 (PDT) Received: by 10.68.43.137 with HTTP; Sun, 30 Oct 2011 12:05:44 -0700 (PDT) Date: Mon, 31 Oct 2011 08:40:00 -0000 Message-ID: Subject: How construct stack frame manually From: zhihua che To: gdb Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2011-10/txt/msg00232.txt.bz2 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.