Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1miKu6-0004dv-SB for mharc-grub-devel@gnu.org; Wed, 03 Nov 2021 14:22:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miKu4-0004Yz-Uz for grub-devel@gnu.org; Wed, 03 Nov 2021 14:22:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22778) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1miKu1-0003OP-JT for grub-devel@gnu.org; Wed, 03 Nov 2021 14:22:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635963744; 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=jTuun6O9Q6WF6remLsrhxBtBx0Q5Wo/bbvQ1Jpt5aPo=; b=LGqJ0s9xiOWUbeazTIOkDKXt+hK439ib0Cu8Bp8jsfHrtBuueZ9TyKQvdVRzMgOyU3zFTq 8BvEE0WVNIi3U/v9en5m5bYr1tE/OlDwhWpHO1QkFNB6rgpGaAR/0vPMzmAjjjm/5ZLiUG pk94JOD+u2+yrmf1xD8MtvGQd+SelFA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-441-FxXlffm8Ms-9nvW2KC8Auw-1; Wed, 03 Nov 2021 14:22:23 -0400 X-MC-Unique: FxXlffm8Ms-9nvW2KC8Auw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89E8610A8E01 for ; Wed, 3 Nov 2021 18:22:22 +0000 (UTC) Received: from eesha.redhat.com (unknown [10.22.48.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CDBF60CC4; Wed, 3 Nov 2021 18:22:19 +0000 (UTC) From: Robbie Harwood To: grub-devel@gnu.org Cc: Robbie Harwood Subject: [PATCH v2 1/2] Add gdb-friendly output support to grub_real_dprintf() Date: Wed, 3 Nov 2021 14:22:06 -0400 Message-Id: <20211103182207.118313-2-rharwood@redhat.com> In-Reply-To: <20211103182207.118313-1-rharwood@redhat.com> References: <20211103182207.118313-1-rharwood@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=rharwood@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Received-SPF: pass client-ip=216.205.24.124; envelope-from=rharwood@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.717, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2021 18:22:29 -0000 When condition is gdb, comment out the file/line/system information by prepending '#' and putting the command on its own line. This allows easy copy/pasting of gdb commands into gdb while preserving the information about where the print came from and how to disable it. Signed-off-by: Robbie Harwood --- grub-core/kern/misc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 11b8592c8..7eea900ae 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -182,7 +182,12 @@ grub_real_dprintf (const char *file, const int line, const char *condition, if (grub_debug_enabled (condition)) { - grub_printf ("%s:%d:%s: ", file, line, condition); + /* gdb commands are on their own line to ease copy/pasting into gdb. */ + if (!grub_strcmp(condition, "gdb")) + grub_printf("#%s:%d:%s:\n", file, line, condition); + else + grub_printf ("%s:%d:%s: ", file, line, condition); + va_start (args, fmt); grub_vprintf (fmt, args); va_end (args); -- 2.33.0