From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 7E4EB3858C53 for ; Mon, 15 May 2023 10:08:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7E4EB3858C53 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684145280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HtrjHbrsyaPdY5nevnI3noKNPJfnsU3r+CCpRjr9MsU=; b=SC/a86eD9TW1nPSpdcXmtid5j0SFXil4xuNlZAoPIx7dNSDhYTkw2byRntdPG0pVAHh05v uAAiykSb7ko29SlssA3jbTRWCvaFgqLUv1wzyZ947NWlkSHSRYZlVHLhLacys0X2iNiBDy mOGWZiI7Jbr3z10bR+Oyo2hnSt/yxJg= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-272-SJ8PdT7MOwqQHXEUBmgQMQ-1; Mon, 15 May 2023 06:07:57 -0400 X-MC-Unique: SJ8PdT7MOwqQHXEUBmgQMQ-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-30620ebd3c2so7805759f8f.0 for ; Mon, 15 May 2023 03:07:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684145276; x=1686737276; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HtrjHbrsyaPdY5nevnI3noKNPJfnsU3r+CCpRjr9MsU=; b=PO50+j9P8Ffh/sYbTX19X2KQGpR/8N7sxnXePbFnSDcaubsheFRtr7zbeoedB3v7/Z s7CPUGofzCYhWnCyagbDhm/f2YWppu9EB+lcsXs0hCY9w6X6+j8Ado1JE7rAvukgOyQ4 b+4j9qG/mUT3EFjSBMEcgBV8ZCrGI5/iKh1SuvZDaYMxWJhMftm8QCZVB5X+lgM03tG+ 710rx5VDrxJSq4XLsIlpVMA1Sfzofj8gwZNKL6YJaHbS7Dgnz/frrGUfgVU9vj61Bvm0 0wkgWjSjEHB2wE1Kv2O0AOOuxiVDvr4Ij2dpSF/oGFyHwo4a/pf4koJsyxonYyE6Ok+g rpeQ== X-Gm-Message-State: AC+VfDwrzfXPluC6391F555mKH07K73HGI2hArZMvoFMJbefL6WTf6Sp AOfstfR740cs6SUXsoby9aJMlqXNop8q0eFybr/YHDOR+WjmAvjvAUks5s8y4xrQHmqBdDhxObI +jAVSBiztORWRbbyUj2q36A== X-Received: by 2002:a5d:4388:0:b0:2f8:3225:2bc1 with SMTP id i8-20020a5d4388000000b002f832252bc1mr24274304wrq.41.1684145276659; Mon, 15 May 2023 03:07:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ40mV2gDJDqDL5NaYWv34Bht/kKP9whdJMpA3LJQY26XZnzzGwxggEvkJdVxXX9G0PmrIA/Ww== X-Received: by 2002:a5d:4388:0:b0:2f8:3225:2bc1 with SMTP id i8-20020a5d4388000000b002f832252bc1mr24274293wrq.41.1684145276233; Mon, 15 May 2023 03:07:56 -0700 (PDT) Received: from localhost (11.72.115.87.dyn.plus.net. [87.115.72.11]) by smtp.gmail.com with ESMTPSA id f16-20020a5d4dd0000000b003062ad45243sm31963882wru.14.2023.05.15.03.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 03:07:55 -0700 (PDT) From: Andrew Burgess To: Luis Machado , gdb-patches@sourceware.org Subject: Re: [PATCH] [gdb/aarch64] Handle unknown debug architecture versions more gracefully In-Reply-To: <20230418135313.36300-1-luis.machado@arm.com> References: <20230418135313.36300-1-luis.machado@arm.com> Date: Mon, 15 May 2023 11:07:53 +0100 Message-ID: <877ct96h6u.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Luis Machado via Gdb-patches writes: > In PR 30340 it was reported that a KVM-based AArch64 system's kernel was > returning a debug architecture version of 0 when fetching both the > NT_ARM_HW_WATCH and NT_ARM_HW_BREAK register sets. > > Even though the debug architecture version being reported is invalid, gdb can > still make things work by ignoring that information and relying on the counts > of hardware watchpoints and hardware breakpoints. > > This patch makes gdb handle this situation a bit more gracefully by causing gdb > to warn when it sees an invalid/unknown debug architecture version, but still > allowing gdb to detect the number of hardware watchpoints and hardware > breakpoints available. > > PR tdep/30340 Apparently we no longer need to include this cookie. Just using the bug url should be enough for this commit to be linked bugzilla. > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30340 > --- > gdb/nat/aarch64-linux-hw-point.c | 24 ++++++++++++++++++++---- > 1 file changed, 20 insertions(+), 4 deletions(-) > > diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c > index ccb47cd5aa2..b014d387e1e 100644 > --- a/gdb/nat/aarch64-linux-hw-point.c > +++ b/gdb/nat/aarch64-linux-hw-point.c > @@ -250,10 +250,21 @@ aarch64_linux_get_debug_reg_capacity (int tid) > iov.iov_base = &dreg_state; > iov.iov_len = sizeof (dreg_state); > > + /* It has been reported that under KVM the debug architecture version can > + be reported as 0, which is invalid. But this doesn't mean gdb can't use > + hardware debugging resources. Instead of bailing out, carry on fetching > + the hardware breakpoints/watchpoints count so we can potentially get back > + on track. */ Given my recent comment on pr gdb/30340 you might want to reword the comment a little -- we now understand why we saw 0 in this case. > + > /* Get hardware watchpoint register info. */ > - if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_WATCH, &iov) == 0 > - && compatible_debug_arch (AARCH64_DEBUG_ARCH (dreg_state.dbg_info))) > + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_WATCH, &iov) == 0) > { > + if (!compatible_debug_arch (AARCH64_DEBUG_ARCH (dreg_state.dbg_info))) > + warning (_("Unknown/Invalid debug architecture version %d.\n" > + "Attempting to fetch the number of hardware watchpoints " > + "available."), > + AARCH64_DEBUG_ARCH (dreg_state.dbg_info)); > + > aarch64_num_wp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info); I guess the risk here is that on a later architecture the format of dreg_state might change, in which case reading the wp/bp count might not get the correct result. But in that case we'd print the warning, so when things go wrong later we will have given the user a clue for what the problem might be. So, I think this change seems a reasonable improvement. Reviewed-By: Andrew Burgess Thanks, Andrew > if (aarch64_num_wp_regs > AARCH64_HWP_MAX_NUM) > { > @@ -271,9 +282,14 @@ aarch64_linux_get_debug_reg_capacity (int tid) > } > > /* Get hardware breakpoint register info. */ > - if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_BREAK, &iov) == 0 > - && compatible_debug_arch (AARCH64_DEBUG_ARCH (dreg_state.dbg_info))) > + if (ptrace (PTRACE_GETREGSET, tid, NT_ARM_HW_BREAK, &iov) == 0) > { > + if (!compatible_debug_arch (AARCH64_DEBUG_ARCH (dreg_state.dbg_info))) > + warning (_("Unknown/Invalid debug architecture version %d.\n" > + "Attempting to fetch the number of hardware breakpoints " > + "available."), > + AARCH64_DEBUG_ARCH (dreg_state.dbg_info)); > + > aarch64_num_bp_regs = AARCH64_DEBUG_NUM_SLOTS (dreg_state.dbg_info); > if (aarch64_num_bp_regs > AARCH64_HBP_MAX_NUM) > { > -- > 2.25.1