From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29936 invoked by alias); 22 Feb 2007 21:56:35 -0000 Received: (qmail 29927 invoked by uid 22791); 22 Feb 2007 21:56:35 -0000 X-Spam-Check-By: sourceware.org Received: from gateway.codesourcery.com (HELO sparrowhawk.codesourcery.com) (65.74.133.9) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 22 Feb 2007 21:56:30 +0000 Received: from sparrowhawk.codesourcery.com (localhost.localdomain [127.0.0.1]) by sparrowhawk.codesourcery.com (8.13.1/8.13.1) with ESMTP id l1MLuSoe006261 for ; Thu, 22 Feb 2007 13:56:28 -0800 Received: (from mitchell@localhost) by sparrowhawk.codesourcery.com (8.13.1/8.13.1/Submit) id l1MLuSqs006149; Thu, 22 Feb 2007 13:56:28 -0800 Date: Thu, 22 Feb 2007 21:56:00 -0000 Message-Id: <200702222156.l1MLuSqs006149@sparrowhawk.codesourcery.com> From: Mark Mitchell To: gdb-patches@sourceware.org Subject: PATCH: Fix ARM simulator buglet Reply-to: mark@codesourcery.com Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-02/txt/msg00285.txt.bz2 This patch fixes a bug in the ARM simulator. In particular, it was unconditionally setting errno to EBADF when asked for the length of file descriptor zero. That's probably not the right error code when that's stdin, but, worse, it's not right to issue an error at all when file descriptor zero is connected to a real file, as can happen when freopen is applied to stdin. The right approach is just to let the ordinary code in the function run, which passes the call down through the generic GDB simulator semihosting layer. I've tested this with a CodeSourcery arm-eabi toolchain, with good results. OK to apply? -- Mark Mitchell CodeSourcery mark@codesourcery.com (650) 331-3385 x713 2007-02-22 Mark Mitchell sim/arm/ * armos.c (SWIflen): Do not treate file descriptor zero as special. Index: sim/arm/armos.c =================================================================== --- sim/arm/armos.c (revision 163133) +++ sim/arm/armos.c (working copy) @@ -401,7 +401,7 @@ SWIflen (ARMul_State * state, ARMword fh struct OSblock *OSptr = (struct OSblock *) state->OSptr; ARMword addr; - if (fh == 0 || fh > FOPEN_MAX) + if (fh > FOPEN_MAX) { OSptr->ErrorNo = EBADF; state->Reg[0] = -1L;