From patchwork Fri Nov 3 08:56:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yao Qi X-Patchwork-Id: 24065 Received: (qmail 12307 invoked by alias); 3 Nov 2017 08:56:13 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 12249 invoked by uid 89); 3 Nov 2017 08:56:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=xs, H*i:sk:1509699, 10658, H*MI:sk:1509699 X-HELO: mail-wm0-f65.google.com Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 03 Nov 2017 08:56:11 +0000 Received: by mail-wm0-f65.google.com with SMTP id r196so3589238wmf.2 for ; Fri, 03 Nov 2017 01:56:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=HdbfxFsC2MpgiRN7scjcfMVCvd+3VyeAMWFxsPoX+98=; b=ebRO+CrcF3npPBy2JL+qG8rr+wR254DvwZPZpZRYX+bXgOoF9aUOWsqULWIpScxfkz Ao2NgZKSCpu2oK5kBzi2up7PQoZWKwBgg2XUy9TRkJdNslT7Hs1JbWY7qRd+xPJNfKnq VXSC570CR8eRoaAc89zJPI4Zu3kpwpAfEEmoNZ7EFuwazPBFcuMP2FSjxakvUqMIIs+v GziGmWfCJhoYzOEQLAIwa0VF5O8YLL5ZaWzONc8vvx51s1l2snUVh9qbGEFABYcg18Z5 ZXQCPf7qmSI5j28RTJ9k5NcFC4hjBzX86RU/2opt+iKU4pE5pgstkV2mureV5Ue0doSE P7NA== X-Gm-Message-State: AMCzsaVIQbfcQsTa6y92rewsYo1EYBNfCiaxFJj+ajVCHOkRszUl+w0+ vePrXxvmyS6cvcnUgwfRc3O9hQ== X-Google-Smtp-Source: ABhQp+R0xpPrLB6K29uzF/NDz4tMGbRERB2sLN7Su4LOFkTEz7swgxfsOmk7CuMsAxWKdSq65zIuHA== X-Received: by 10.28.230.77 with SMTP id d74mr3468597wmh.75.1509699369450; Fri, 03 Nov 2017 01:56:09 -0700 (PDT) Received: from E107787-LIN.cambridge.arm.com (static.42.136.251.148.clients.your-server.de. [148.251.136.42]) by smtp.gmail.com with ESMTPSA id j13sm3627541wrb.18.2017.11.03.01.56.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Nov 2017 01:56:08 -0700 (PDT) From: Yao Qi X-Google-Original-From: Yao Qi To: gdb-patches@sourceware.org Subject: [PATCH 2/2] Change value_contents_eq return bool Date: Fri, 3 Nov 2017 08:56:04 +0000 Message-Id: <1509699364-16049-2-git-send-email-yao.qi@linaro.org> In-Reply-To: <1509699364-16049-1-git-send-email-yao.qi@linaro.org> References: <1509699364-16049-1-git-send-email-yao.qi@linaro.org> X-IsSubscribed: yes This patch changes value_contents_eq return type from int to bool. gdb: 2017-11-01 Yao Qi * mi/mi-main.c (register_changed_p): Update. * value.c (value_contents_bits_eq): Change return type. (value_contents_eq): Likewise. * value.h: Update comments. --- gdb/mi/mi-main.c | 4 ++-- gdb/value.c | 10 +++++----- gdb/value.h | 24 ++++++++++++------------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 42df94e..8f9b7e4 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1065,8 +1065,8 @@ register_changed_p (int regnum, struct regcache *prev_regs, gdb_assert (prev_value != NULL); gdb_assert (this_value != NULL); - auto ret = value_contents_eq (prev_value, 0, this_value, 0, - register_size (gdbarch, regnum)) == 0; + auto ret = !value_contents_eq (prev_value, 0, this_value, 0, + register_size (gdbarch, regnum)); release_value (prev_value); release_value (this_value); diff --git a/gdb/value.c b/gdb/value.c index 7d0966c..f3b0288 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -810,7 +810,7 @@ find_first_range_overlap_and_match (struct ranges_and_idx *rp1, with LENGTH bits of VAL2's contents starting at OFFSET2 bits. Return true if the available bits match. */ -static int +static bool value_contents_bits_eq (const struct value *val1, int offset1, const struct value *val2, int offset2, int length) @@ -849,7 +849,7 @@ value_contents_bits_eq (const struct value *val1, int offset1, if (!find_first_range_overlap_and_match (&rp1[i], &rp2[i], offset1, offset2, length, &l_tmp, &h_tmp)) - return 0; + return false; /* We're interested in the lowest/first range found. */ if (i == 0 || l_tmp < l) @@ -862,17 +862,17 @@ value_contents_bits_eq (const struct value *val1, int offset1, /* Compare the available/valid contents. */ if (memcmp_with_bit_offsets (val1->contents, offset1, val2->contents, offset2, l) != 0) - return 0; + return false; length -= h; offset1 += h; offset2 += h; } - return 1; + return true; } -int +bool value_contents_eq (const struct value *val1, LONGEST offset1, const struct value *val2, LONGEST offset2, LONGEST length) diff --git a/gdb/value.h b/gdb/value.h index cfc8cae..8f8f960 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -550,12 +550,12 @@ extern void mark_value_bits_unavailable (struct value *value, then: - value_contents_eq(val, 0, val, 8, 6) => 1 - value_contents_eq(val, 0, val, 4, 4) => 0 - value_contents_eq(val, 0, val, 8, 8) => 0 - value_contents_eq(val, 4, val, 12, 2) => 1 - value_contents_eq(val, 4, val, 12, 4) => 0 - value_contents_eq(val, 3, val, 4, 4) => 0 + value_contents_eq(val, 0, val, 8, 6) => true + value_contents_eq(val, 0, val, 4, 4) => false + value_contents_eq(val, 0, val, 8, 8) => false + value_contents_eq(val, 4, val, 12, 2) => true + value_contents_eq(val, 4, val, 12, 4) => true + value_contents_eq(val, 3, val, 4, 4) => true If 'x's represent an unavailable byte, 'o' represents an optimized out byte, in a value with length 8: @@ -565,9 +565,9 @@ extern void mark_value_bits_unavailable (struct value *value, then: - value_contents_eq(val, 0, val, 2, 2) => 1 - value_contents_eq(val, 4, val, 6, 2) => 1 - value_contents_eq(val, 0, val, 4, 4) => 0 + value_contents_eq(val, 0, val, 2, 2) => true + value_contents_eq(val, 4, val, 6, 2) => true + value_contents_eq(val, 0, val, 4, 4) => true We only know whether a value chunk is unavailable or optimized out if we've tried to read it. As this routine is used by printing @@ -575,9 +575,9 @@ extern void mark_value_bits_unavailable (struct value *value, after the inferior is gone, it works with const values. Therefore, this routine must not be called with lazy values. */ -extern int value_contents_eq (const struct value *val1, LONGEST offset1, - const struct value *val2, LONGEST offset2, - LONGEST length); +extern bool value_contents_eq (const struct value *val1, LONGEST offset1, + const struct value *val2, LONGEST offset2, + LONGEST length); /* Read LENGTH addressable memory units starting at MEMADDR into BUFFER, which is (or will be copied to) VAL's contents buffer offset by