From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61326 invoked by alias); 18 Sep 2016 23:26:05 -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 61297 invoked by uid 89); 18 Sep 2016 23:26:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.0 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 18 Sep 2016 23:25:53 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEBE51146FB for ; Sun, 18 Sep 2016 23:25:52 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8INPp5m009903 for ; Sun, 18 Sep 2016 19:25:52 -0400 Subject: [pushed] gdb: Fix std::{min, max}-related build breakage on 32-bit hosts To: gdb-patches@sourceware.org References: <1473958336-23920-1-git-send-email-palves@redhat.com> <4e2937a7-f70d-574f-75b8-78faab90fddc@ericsson.com> <77416303-1ed7-fe71-7a52-1dbd1ca6aa56@redhat.com> From: Pedro Alves Message-ID: <2048ff63-1438-8776-7a31-8ce38dc80e05@redhat.com> Date: Sun, 18 Sep 2016 23:26:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <77416303-1ed7-fe71-7a52-1dbd1ca6aa56@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-SW-Source: 2016-09/txt/msg00198.txt.bz2 On 09/16/2016 08:00 PM, Pedro Alves wrote: > From 325fac504a327de9c46a4e5cf9c88ece9d9d7701 Mon Sep 17 00:00:00 2001 > From: Pedro Alves > Date: Fri, 16 Sep 2016 19:55:17 +0100 > Subject: [PATCH] gdb: Use std::min and std::max throughout This broke the build on 32-bit hosts, where CORE_ADDR is 32-bit. I've pushed the fix. >From 768adc05c44c7e8b5c0f9ca5ad3ca96657715293 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Sun, 18 Sep 2016 23:56:01 +0100 Subject: [PATCH] gdb: Fix std::{min, max}-related build breakage on 32-bit hosts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Building on a 32-bit host fails currently with errors like: .../src/gdb/exec.c: In function ‘target_xfer_status section_table_read_available_memory(gdb_byte*, ULONGEST, ULONGEST, ULONGEST*)’: .../src/gdb/exec.c:801:54: error: no matching function for call to ‘min(ULONGEST, long unsigned int)’ end = std::min (offset + len, r->start + r->length); ^ In file included from /usr/include/c++/5.3.1/algorithm:61:0, from .../src/gdb/exec.c:46: /usr/include/c++/5.3.1/bits/stl_algobase.h:195:5: note: candidate: template const _Tp& std::min(const _Tp&, const _Tp&) min(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/5.3.1/bits/stl_algobase.h:195:5: note: template argument deduction/substitution failed: .../src/gdb/exec.c:801:54: note: deduced conflicting types for parameter ‘const _Tp’ (‘long long unsigned int’ and ‘long unsigned int’) end = std::min (offset + len, r->start + r->length); ^ In file included from /usr/include/c++/5.3.1/algorithm:61:0, from .../src/gdb/exec.c:46: /usr/include/c++/5.3.1/bits/stl_algobase.h:243:5: note: candidate: template const _Tp& std::min(const _Tp&, const _Tp&, _Compare) min(const _Tp& __a, const _Tp& __b, _Compare __comp) ^ The problem is that the std::min/std::max function templates use the same type for both parameters. When the argument types are different, the compiler can't automatically deduce which template specialization to pick from the arguments' types. Fix that by specifying the specialization we want explicitly. gdb/ChangeLog: 2016-09-18 Pedro Alves * breakpoint.c (hardware_watchpoint_inserted_in_range): Explicitly specify the std:min/std::max specialization. * exec.c (section_table_read_available_memory): Likewise. * remote.c (remote_read_qxfer): Likewise. * target.c (simple_verify_memory): Likewise. --- gdb/ChangeLog | 8 ++++++++ gdb/breakpoint.c | 4 ++-- gdb/exec.c | 2 +- gdb/remote.c | 2 +- gdb/target.c | 2 +- 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2c980b7..f86e0a4 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,11 @@ +2016-09-18 Pedro Alves + + * breakpoint.c (hardware_watchpoint_inserted_in_range): Explicitly + specify the std:min/std::max specialization. + * exec.c (section_table_read_available_memory): Likewise. + * remote.c (remote_read_qxfer): Likewise. + * target.c (simple_verify_memory): Likewise. + 2016-09-16 Simon Marchi * infrun.c (restore_current_uiout_cleanup): Move to ui-out.c. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 28331f1..1e05932 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -4436,8 +4436,8 @@ hardware_watchpoint_inserted_in_range (struct address_space *aspace, CORE_ADDR l, h; /* Check for intersection. */ - l = std::max (loc->address, addr); - h = std::min (loc->address + loc->length, addr + len); + l = std::max (loc->address, addr); + h = std::min (loc->address + loc->length, addr + len); if (l < h) return 1; } diff --git a/gdb/exec.c b/gdb/exec.c index b18ca8b..7435971 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -798,7 +798,7 @@ section_table_read_available_memory (gdb_byte *readbuf, ULONGEST offset, enum target_xfer_status status; /* Get the intersection window. */ - end = std::min (offset + len, r->start + r->length); + end = std::min (offset + len, r->start + r->length); gdb_assert (end - offset <= len); diff --git a/gdb/remote.c b/gdb/remote.c index 2309205..e80db79 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -9907,7 +9907,7 @@ remote_read_qxfer (struct target_ops *ops, const char *object_name, may not, since we don't know how much of it will need to be escaped; the target is free to respond with slightly less data. We subtract five to account for the response type and the protocol frame. */ - n = std::min (get_remote_packet_size () - 5, len); + n = std::min (get_remote_packet_size () - 5, len); snprintf (rs->buf, get_remote_packet_size () - 4, "qXfer:%s:read:%s:%s,%s", object_name, annex ? annex : "", phex_nz (offset, sizeof offset), diff --git a/gdb/target.c b/gdb/target.c index 628bceb..b93244d 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3585,7 +3585,7 @@ simple_verify_memory (struct target_ops *ops, ULONGEST xfered_len; enum target_xfer_status status; gdb_byte buf[1024]; - ULONGEST howmuch = std::min (sizeof (buf), size - total_xfered); + ULONGEST howmuch = std::min (sizeof (buf), size - total_xfered); status = target_xfer_partial (ops, TARGET_OBJECT_MEMORY, NULL, buf, NULL, lma + total_xfered, howmuch, -- 2.5.5