From patchwork Thu Nov 30 18:44:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 56436 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 00C98385C32C for ; Thu, 30 Nov 2023 18:51:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 6D04C3858D37 for ; Thu, 30 Nov 2023 18:50:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6D04C3858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6D04C3858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701370250; cv=none; b=FZbhqz6lzVLZl8IF7iWgpmSgoTNafm3tEhe4kpcU4GVyDxlayQiPd7He8uxFftJ0eLaWNUOzbZdy0zVpVZBG0/VxnzIwNdg3pTATkA8oYmKYBEiRFZbBU4Veulzc3n0X7rVxR8IZLS8qCylG9EF8wnVd7VnGjO9op8pI3iT+B90= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701370250; c=relaxed/simple; bh=DEE5vv/mqhbBMtXz+05jTSwbNBajVlQKgcn+NKsg4f4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=QrHrq9hrmfPrltMd2Sul0C8OWBK0Lj5QdQvrVJXMcnnEuDXrreIJEqQz8LGBuYLm0zk6HRt7ItLxFpABeFNdQ6mTgQE950cohsEuA5n9LYNCU8v1RC+EHHeZtkL+xrfBrA4c39d1pvczpvlS1jrg7PYCxf1VrxrDqRWLwLlvmjA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701370249; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wxkRatLuZueS71fxUz77H+rLaf1fkL3ZmaHJAp9s55Q=; b=afiaDeH85VBOwjB0KuggC2BB+oxkJz8mNOLW81CgmGC94RpUZ/uAQc1MgroYSRiRgKpDqi 3kPnZq6c+Qj2z1JttHfa2Lya2QLLUoKfN0JjHodMqSYQ8n1zdc5WOmKgUdENmq0b7Xq/vJ jySh7yn6jtCCNSJ8zBcMIdTdQGAFV14= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-369-jnegxbvAOVupbQah3pFnlA-1; Thu, 30 Nov 2023 13:50:47 -0500 X-MC-Unique: jnegxbvAOVupbQah3pFnlA-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-50bc6704477so1280183e87.3 for ; Thu, 30 Nov 2023 10:50:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701370245; x=1701975045; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wxkRatLuZueS71fxUz77H+rLaf1fkL3ZmaHJAp9s55Q=; b=EjZxxiJt1hN3b0ClmKkbi7eKCjGa42MBEAh/KPsyrHC1o0Zyi8zMqxl6Z+ebTqUBrV wpdSlP31UPB9CLP6o6YPSXuAwxIe1I6pxYvDm3jagN4OBJ8+4A4GEld+nC+befUp0qzP WtGNZXq2zNkyJfrmKzUeM7ZGEwadqK2Kmz/18OnrWcUVSD9vpImP1spSalzOjdxPDYWc 5qk12tSeFvyL4sOeU0OKEXEZqpv1NdqB/1buteiLRfIqArER9ibrKI30eKwr+i+R4Hmn TTqQSXZ6LxT/J7y2sCvWW9Koxe8NxHVYvIjJ6tyYuAIcwcFWvdm2DNkSWfgV8oa9uUUa ez5A== X-Gm-Message-State: AOJu0YxkUUURSSxW3AaMaRV03RM0twjNtgR3L2Kiv1/BQtt3Xgnii98u P3fi+k+++I7tCuDZKda1H6DMpm8HOtcORBPJ5DXIdwr2ZMyFdvpHhkyVGk31nu54ooCX2bx1wvy haF0yGXpixUFj+iokI4QsHqrfDmbvwgd37NroznOP5bNsM0XAczsFLTU94HFTnQmpqyLGDIQBME fW01HUpA== X-Received: by 2002:a05:6512:224b:b0:50b:d763:fe3e with SMTP id i11-20020a056512224b00b0050bd763fe3emr1167lfu.89.1701370244323; Thu, 30 Nov 2023 10:50:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGjiR1+lXlkRlhLEcCYFRy1v+8MF6+TMbsGrtm16RYWnktXNJfK/4YsARHRD+XDGdQtQtZzuw== X-Received: by 2002:a50:bb0f:0:b0:54b:8c96:9aa6 with SMTP id y15-20020a50bb0f000000b0054b8c969aa6mr665ede.37.1701369864575; Thu, 30 Nov 2023 10:44:24 -0800 (PST) Received: from localhost (92.40.185.184.threembb.co.uk. [92.40.185.184]) by smtp.gmail.com with ESMTPSA id f25-20020a056402151900b0054bae7dc6c8sm815800edw.50.2023.11.30.10.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 10:44:24 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCHv2 0/3] Improve debug output support in gdbserver Date: Thu, 30 Nov 2023 18:44:15 +0000 Message-Id: X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Changes since v1: - I've now dropped the --remote-debug and --event-loop-debug command line options, - I've now dropped the 'monitor set remote-debug' and 'monitor set event-loop-debug' monitor commands, - I've fixed some of Eli's doc feedback. We still have the duplication between the man page and info manual content. I'm not sure if that can easily be fixed as part of this commit, or if that should be a separate piece of work, - Now accept on/off instead of 1/0 in the monitor commands, - Now allow 'all' as a component in the monitor commands. Preventing this before was pretty arbitrary, and on reflection seemed pointless, - Fixed a bug where the 'all' component would only actually enable the 'threads' component, - The first patch of the prevoius series has been pushed. But I have a new first patch which fixes another gdbserver debug related issue. --- For another patch I'm working on I wanted to add some additional debug output to gdbserver. Right now there appears to be two broad approaches I could take, these are: 1. Just use threads_debug_printf. The comments in debug.h even claim that this is really the "general" gdbserver debug output and that the "threads" here is just historic, but that feels like a bit of a cop out, we do have separate remote and event-loop debug control. I think what really happened is folk just started reusing the threads_debug_printf rather than adding a new debug category, and over time we just resigned ourselves to threads actually being general output... I think we can do better than that, so 2. We can add a whole new debug category, with a new *_debug_printf function. That I think would be better, but to control this new debug flag we then need to add a new command line flag (we already have --debug, --remote-debug, and --event-loop-debug), and then we need to add new monitor commands to control this new debug setting... this begins to feel not very scalable. So, in this series I try to reimagine debug control in gdbserver. The gdbserver command line flag now takes an optional list of components, so we can do: gdbserver --debug=remote,threads to enable 'remote' and 'threads' debug. The default if no components are listed is 'threads', which retains backwards compatibility with the current behaviour, thought we might want to change this in the future. I've also removed the two existing flags '--remote-debug' and '--event-loop-debug', instead we should now do '--debug=remote', '--debug=event-loop', or '--debug=remote,event-loop' as needed. And on the monitor command side, we now support: (gdb) monitor set debug COMPONENT on (gdb) monitor set debug COMPONENT off to enable and disable debug for COMPONENT. Where COMPONENT is again, 'all', 'threads', 'remote', and 'event-loop'. Again, I've retained: (gdb) monitor set debug on As a synonym for 'monitor set debug threads on', but I have changed: (gdb) monitor set debug off Which now disables all debugging output from gdbserver. Notice also that I'm not using 'on' and 'off' in the monitor commands rather than '1' and '0'. The old 1/0 still works, but on/off is what the docs now suggest; this seemed to better match GDB's internal settings. I have removed the monitor command: (gdb) monitor set remote-debug 0|1 (gdb) monitor set event-loop-debug 0|1 These commands are replaces by using the 'remote' or 'event-loop' components as needed. --- Andrew Burgess (3): gdb: fix GDB_DEBUG and GDBSERVER_DEBUG Makefile variables gdbserver: allow the --debug command line option to take a value gdbserver: allow for general 'monitor set debug COMPONENT VALUE' use gdb/Makefile.in | 5 +- gdb/NEWS | 18 ++ gdb/doc/gdb.texinfo | 98 ++++++-- gdb/testsuite/gdb.server/server-mon.exp | 25 +- gdbserver/server.cc | 315 +++++++++++++++++++++--- 5 files changed, 397 insertions(+), 64 deletions(-) base-commit: a393b155174d20d3d120b5012b87c5438ab9e3d4