From patchwork Wed May 6 05:51:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1284070 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49H5Lt0KqGz9sSt for ; Wed, 6 May 2020 15:51:34 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=P7pVtTGN; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49H5Ls6k97zDql9 for ; Wed, 6 May 2020 15:51:33 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49H5Lp2Jm7zDqBy for ; Wed, 6 May 2020 15:51:30 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=P7pVtTGN; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 49H5Ln6jpbz9sRY; Wed, 6 May 2020 15:51:29 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1588744290; bh=+NV3gxPSGdrCEJZKtyNWPszSZxP6Z9AsKPOEJFK+d/Q=; h=From:To:Cc:Subject:Date:From; b=P7pVtTGNMHAZV3G+oZ2Jc7PV+6Nfu2Hf+SusPPByZ3yn3VzFLZga4EXrx/531QMdJ JLfTtbMy/GGpmcRXf8bZV6n69ujJUsMW/m/tz80z8m95L1sF+8JdOkGSujhkc+zJN0 QMRzjNOSYTwvZb6O6iedE+esHK4+3WyxwcCzPbRquRCKCnf8AAilNjZ3AE7N5xop0b 3C60GE8YuZk/lu3/DBZxYel6mfWZd6fxvqTPBgIGWNLaT8s1RiYYZzzeODpp7QpI7R 6d3CGyc6eMxADSU7/rC2xGrRtpQuMlmARMTZc0XmInacd9RnAl2+UsdGjfVX/GY5NL wNspuzQ64wkzw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Wed, 6 May 2020 15:51:25 +1000 Message-Id: <20200506055125.154002-1-amitay@ozlabs.org> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Subject: [Pdbg] [PATCH] libpdbg: Add count to attribute_(get|set)_packed X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Allow arrays of packed integers as attribute values. Signed-off-by: Amitay Isaacs --- libpdbg/device.c | 114 +++++++++++++++++++--------------- libpdbg/libpdbg.h | 6 +- src/tests/libpdbg_attr_test.c | 111 ++++++++++++++++++--------------- tests/test_attr_packed.sh | 36 ++++++----- 4 files changed, 148 insertions(+), 119 deletions(-) diff --git a/libpdbg/device.c b/libpdbg/device.c index 219569e..9459abe 100644 --- a/libpdbg/device.c +++ b/libpdbg/device.c @@ -868,58 +868,64 @@ static size_t spec_size(const char *spec) return size; } -bool pdbg_target_set_attribute_packed(struct pdbg_target *target, const char *name, const char *spec, const void *val) +bool pdbg_target_set_attribute_packed(struct pdbg_target *target, const char *name, const char *spec, uint32_t count, const void *val) { void *buf; - size_t size, pos, i; + size_t size, pos, i, j; bool ok; if (!spec || spec[0] == '\0') return false; + if (count == 0) + return false; + size = spec_size(spec); if (size <= 0) return false; + size = size * count; buf = malloc(size); if (!buf) return false; pos = 0; - for (i=0; i read array 1|2|4|8 \n"); fprintf(stderr, " libpdbg_attr_test write array 1|2|4|8 [ ...]\n"); - fprintf(stderr, " libpdbg_attr_test read packed \n"); - fprintf(stderr, " libpdbg_attr_test write packed [ ...]\n"); + fprintf(stderr, " libpdbg_attr_test read packed \n"); + fprintf(stderr, " libpdbg_attr_test write packed [ ...]\n"); exit(1); } @@ -143,48 +143,53 @@ static size_t spec_size(const char *spec) static void read_packed(struct pdbg_target *target, const char *attr, - const char *spec) + const char *spec, + unsigned int count) { void *buf; size_t size, pos; - unsigned int i; + unsigned int i, j; size = spec_size(spec); assert(size > 0); + size = size * count; + buf = malloc(size); assert(buf); - if (!pdbg_target_get_attribute_packed(target, attr, spec, buf)) + if (!pdbg_target_get_attribute_packed(target, attr, spec, count, buf)) exit(88); pos = 0; - for (i=0; i 0); + size = size * count; buf = malloc(size); assert(buf); pos = 0; - for (i=0; i