From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23736 invoked by alias); 15 Apr 2004 09:20:52 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 23721 invoked from network); 15 Apr 2004 09:20:49 -0000 Received: from unknown (HELO services.exanet.com) (212.143.73.102) by sources.redhat.com with SMTP; 15 Apr 2004 09:20:49 -0000 Received: from exanet.com ([10.0.6.84]) by services.exanet.com with Microsoft SMTPSVC(5.0.2195.2966); Thu, 15 Apr 2004 12:20:47 +0300 Message-ID: <407E53EF.8010203@exanet.com> Date: Thu, 15 Apr 2004 17:45:00 -0000 From: Avi Kivity User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1) Gecko/20031027 MIME-Version: 1.0 To: gdb@sources.redhat.com Subject: setting $ebp fails? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 15 Apr 2004 09:20:47.0543 (UTC) FILETIME=[EFD15C70:01C422CA] X-SW-Source: 2004-04/txt/msg00085.txt.bz2 I have a user-level threads package on x86, which does the usual setjmp() tricks to switch stacks. Unfortunately, the application which sits atop this package experiences the occasional bug, so I wrote a few user-defined gdb commands to help with debugging: define tio_switchto echo before switchto set $new_esp = (('TioSingle::Thread'*)(($arg0)._impl)).state.esp echo after esp set $new_ebp = (('TioSingle::Thread'*)(($arg0)._impl)).state.ebp echo after ebp set $new_eip = (('TioSingle::Thread'*)(($arg0)._impl)).state.eip echo after eip set $eip = $new_eip echo after new_eip set $esp = $new_esp echo after new_esp set $ebp = $new_ebp echo after new_ebp echo after switchto end tio_switchto expects a pointer to a user-level thread in $arg0, extracts the state from the saved context, and sets the processor registers so that commands like 'backtrace' and examination of stack variables can work. gdb, however, fails after the 'set $ebp' line. It appears to have executed ($ebp is equal to $new_ebp), but execution of the script stops: before switchto after esp after ebp after eip after new_eip after new_esp Cannot access memory at address 0xb73a0000 'backtrace' after this failure gives the expected results, and mentions the faulting address, but I don't see why 'echo' should trigger that: (gdb) bt #0 0x08405b29 in setjmp (buf=@0x86f3360) at shmsync/setjmp.cpp:8 #1 0x083fe3de in TioSingle::Thread::suspend (this=0x8702338) at shmsync/single.cpp:165 #2 0x083c565c in TioThread::suspend (this=0x8702230) at tio.hpp:18 [...] #14 0x083fde9c in TioSingle::Thread::setup_stack (thread=0x8702338, creator=0xb73df4f4) at shmsync/single.cpp:98 #15 0xb7459854 in makecontext () from /lib/i686/libc.so.6 #16 0x08702338 in ?? () #17 0xb73df4f4 in ?? () #18 0x00000000 in ?? () Cannot access memory at address 0xb73a0000 Linux 2.4 on i386, C++, gdb-20040413. Any help would be appreciated. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic.