From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21723 invoked by alias); 19 Mar 2013 15:14:40 -0000 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 Received: (qmail 21710 invoked by uid 89); 19 Mar 2013 15:14:40 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from aquarius.hirmke.de (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 19 Mar 2013 15:14:37 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 580A05203F8; Tue, 19 Mar 2013 16:14:36 +0100 (CET) Date: Tue, 19 Mar 2013 16:24:00 -0000 From: Corinna Vinschen To: gdb-patches@sourceware.org Subject: [patch] windows-nat.c: Fix offset problem in signal string handling Message-ID: <20130319151436.GB20727@calimero.vinschen.de> Reply-To: gdb-patches@sourceware.org Mail-Followup-To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2013-03/txt/msg00714.txt.bz2 Hi, another problem I found when trying the Cygwin signal handling on 64 bit is that the address string of the context information can't be fetched, because the pointer `p' points to the space in front of the address string, but string_to_core_addr doesn't handle leading spaces. The easiest way to fix this is to change the call to string_to_core_addr(p) in handle_output_debug_string to `string_to_core_addr (p + 1)'. Alternatively the call to string_to_core_addr could be replaced with a call to `strtoull (p, NULL, 0)'. Since this code is only supported on Cygwin, it's safe to assume that the strtoull function exists. So I have two variations of the patch, I apply whatever you think is best. Thanks, Corinna Version 1: * windows-nat.c (handle_output_debug_string): Fix offset in call to string_to_core_addr. Index: windows-nat.c =================================================================== RCS file: /cvs/src/src/gdb/windows-nat.c,v retrieving revision 1.242 diff -u -p -r1.242 windows-nat.c --- windows-nat.c 19 Mar 2013 15:06:26 -0000 1.242 +++ windows-nat.c 19 Mar 2013 15:11:55 -0000 @@ -978,7 +978,7 @@ handle_output_debug_string (struct targe retval = strtoul (p, &p, 0); if (!retval) retval = main_thread_id; - else if ((x = (LPCVOID) string_to_core_addr (p)) + else if ((x = (LPCVOID) string_to_core_addr (p + 1)) && ReadProcessMemory (current_process_handle, x, &saved_context, __COPY_CONTEXT_SIZE, &n) Version 2: * windows-nat.c (handle_output_debug_string): Replace call to string_to_core_addr with call to strtoull. Index: windows-nat.c =================================================================== RCS file: /cvs/src/src/gdb/windows-nat.c,v retrieving revision 1.242 diff -u -p -r1.242 windows-nat.c --- windows-nat.c 19 Mar 2013 15:06:26 -0000 1.242 +++ windows-nat.c 19 Mar 2013 15:13:10 -0000 @@ -978,7 +978,7 @@ handle_output_debug_string (struct targe retval = strtoul (p, &p, 0); if (!retval) retval = main_thread_id; - else if ((x = (LPCVOID) string_to_core_addr (p)) + else if ((x = (LPCVOID) strtoull (p, NULL, 0)) && ReadProcessMemory (current_process_handle, x, &saved_context, __COPY_CONTEXT_SIZE, &n) -- Corinna Vinschen Cygwin Maintainer Red Hat