From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23657 invoked by alias); 16 Jun 2006 12:58:38 -0000 Received: (qmail 23647 invoked by uid 22791); 16 Jun 2006 12:58:37 -0000 X-Spam-Check-By: sourceware.org Received: from wx-out-0102.google.com (HELO wx-out-0102.google.com) (66.249.82.204) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 16 Jun 2006 12:58:35 +0000 Received: by wx-out-0102.google.com with SMTP id t13so431646wxc for ; Fri, 16 Jun 2006 05:58:33 -0700 (PDT) Received: by 10.70.116.8 with SMTP id o8mr3938648wxc; Fri, 16 Jun 2006 05:58:33 -0700 (PDT) Received: by 10.70.26.5 with HTTP; Fri, 16 Jun 2006 05:58:33 -0700 (PDT) Message-ID: <40c9f5b20606160558v277bb813r9d5a497c9899432@mail.gmail.com> Date: Fri, 16 Jun 2006 12:58:00 -0000 From: "zhigang gong" To: gdb-patches@sources.redhat.com Subject: Wrong data type in function unpack_varlen_hex() MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-06/txt/msg00237.txt.bz2 Hi, I am working on an mips4k platform. When I added hw watchpoint support for my target board and debug it with gdb. The write watchpoint works fine, but rwatch and awatch doesn't work. After trace the source code of the gdb, I found there is a bug in unpack_varlen_hex. The local variable retval is a signed integer. For my case, the ULONGEST is a 64bit integer type. So when the watchpoint's address is 0x8XXXXXXX, the "retval" will be 0x8XXXXXXX, and pass its value to variable "result", the "result"'s value will be sign extended to 0xFFFFFFFF8XXXXXXX. Then when i set a rwatch point, the address matching will fail when the read watchpoint ocurred. The patch is as belows. And I test it, --- src/gdb/remote.c 2006-05-06 04:08:45.000000000 +0800 +++ insight-6550-060529/gdb/remote.c 2006-06-15 19:26:46.000000000 +0800 @@ -1125,7 +1125,7 @@ ULONGEST *result) { int nibble; - int retval = 0; + ULONGEST retval = 0; while (ishex (*buff, &nibble)) { --- src/gdb/ChangeLog 2006-05-28 13:56:50.000000000 +0800 +++ insight-6550-060529/gdb/ChangeLog 2006-06-16 09:19: 55.000000000 +0800 @@ -1,3 +1,8 @@ +2006-06-16 Zhigang Gong < zhigang.gong@gmail.com> + * remote.c(unpack_varlen_hex): + Change the type of local variable "retval" to ULONGEST, so it will avoid + incorrect sign extending. + 2006-05-28 Alexandre Oliva < aoliva@redhat.com> Best Regards, Zhigang Gong