Message ID | 20231121222019.646253-1-dmalcolm@redhat.com |
---|---|
Headers |
Return-Path: <binutils-bounces+ouuuleilei=gmail.com@sourceware.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp949640vqb; Tue, 21 Nov 2023 14:20:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdQHYUOviWRQK/xOU6MQ0MhgnqCEx9Jh1YTN4aUVjQupqPJFVXc6T7JHMUPjVRVc7tA9Wm X-Received: by 2002:ac8:7f8d:0:b0:423:789c:659b with SMTP id z13-20020ac87f8d000000b00423789c659bmr617452qtj.60.1700605249724; Tue, 21 Nov 2023 14:20:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1700605249; cv=pass; d=google.com; s=arc-20160816; b=KVSybOdKeK049YKmx4lscPmXVeLWbAkdC5VDyPQ8BSF3zz/CsnRjN2rm4Kwu0+R6w0 PUqpgHZxr1twM8uNwB1r2DlKkZpynzSBEFbUa9djwGOq2k4W/q3+H1viPSAe5dgzA4RZ zfgJVdeR6ysQaH+KqcGz0xpQ114bD35tTDgzr+p1UdXUe3bqt54GALJYIB1Di8CcOXvm byotdgWvEoAGa4y2uoqsVhlANTyAa1nXsY6T0wIiBHGDKatBQAbGYlPIsxcuTJJICk7Y Tejco6qPJYVa5zifhDj9Qj4Rb36kSMP25x0Iqq/u7d5XhXweow92IJIzJiq+fjJ7H05t eMrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=2gOJzDr4dMZjj3SjwmO2bTcmXVeBjy9hvbcSQym3cwE=; fh=rfR2SIXf27jLXVYT4RHMSVZgLIsrp2E1IHKtUM1Ws70=; b=TNokmknvfLFEfLprqGeRII7hT9e8jkGJiprVMSVy2SbXW3qOi4ZhGs2Zb/QbHjmHd8 ySbUIMJzoKu1AlDDWhoargMtXSwMDWxajTz5S371tNhl8IbyuRipAI+QX0tLaJcI91ow IMu74Ah0KE4RXhdi7zq+4udVJtW9mytPRVDCNsUWQZRu6ryml8z2hUqhXUeW16AoTDsM KLDKuJPezPpD9MmfJfQEP13aJu8EylssfEKMzEntPGncqILFhiykum1Ey+XY96npEhkv kdpYt2Z/O9dTRocCfDACQNW83X89R1D6PiyRQSs6/Vy+oAs73ObvUZN8XfLy0ZrskxlP cK8g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jPoMejvn; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id fb10-20020a05622a480a00b0042378c900afsi623018qtb.386.2023.11.21.14.20.49 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 14:20:49 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jPoMejvn; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D065B385701C for <ouuuleilei@gmail.com>; Tue, 21 Nov 2023 22:20:43 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@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 4BCA33858413 for <binutils@sourceware.org>; Tue, 21 Nov 2023 22:20:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4BCA33858413 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 4BCA33858413 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=1700605225; cv=none; b=JOLRkG2HXGBSaCI06IcgGKeP9///jrTuswDTNcCGr1/W5kY4wAgS7vBiBDCmOE9J+eADhp8bcj1lU2xWkXqo3FxwmfesEONVp4EKq5dmYIhXy4o+E6p/zEFYwLx65shqidOrePgRGpK6e4XfljNIK2OQCwudoT9NlLqG2YnM1Zo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700605225; c=relaxed/simple; bh=z/E15g7YLniLsIHIzyVmfOjlQcgph7WE4FClFJ/tJrA=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=AfnciBeJQmC85Rx1B2lzWx3K6vRLXX14+ufr6Uty4ztXQWNfFRY/0q76HeAdJxDS8tp9A0wPXLOgRzhuQP3xA7mWzaY8IvTCeMC08QLnUH0GiQkW2VXrxCzMYlGczmJbJZwdqJNg9H9/kCXX10oGQ5YlqAKa80+3bBmVMZ9spnQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700605223; 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=2gOJzDr4dMZjj3SjwmO2bTcmXVeBjy9hvbcSQym3cwE=; b=jPoMejvn69oGocahHworpIL1Dg0Pi7C7DM8aO2aOMsyEWyHcjgMr+azJGbhc16O5fmJsTS LqBqKjf2RA7gViUHeDIUInMrZPgaaj+op3KzE7KdNusxsPpxjmbHhrDvxzoG+MNrr2XOJh ipCR2JH4Khyux4c0VWpBY2YJuL+RvPE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-639-vzcnbG4NMZOFFnw_2uV5vQ-1; Tue, 21 Nov 2023 17:20:21 -0500 X-MC-Unique: vzcnbG4NMZOFFnw_2uV5vQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 458A1185A782; Tue, 21 Nov 2023 22:20:21 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.22.10.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8A7C492BFA; Tue, 21 Nov 2023 22:20:20 +0000 (UTC) From: David Malcolm <dmalcolm@redhat.com> To: gcc-patches@gcc.gnu.org, binutils@sourceware.org Cc: Nick Clifton <nickc@redhat.com>, Simon Sobisch <simonsobisch@gnu.org>, David Malcolm <dmalcolm@redhat.com> Subject: [PATCH 0/6] v2 of libdiagnostics Date: Tue, 21 Nov 2023 17:20:13 -0500 Message-Id: <20231121222019.646253-1-dmalcolm@redhat.com> In-Reply-To: <20231106222959.2707741-1-dmalcolm@redhat.com> References: <20231106222959.2707741-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, LIKELY_SPAM_BODY, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783213850644820180 X-GMAIL-MSGID: 1783213850644820180 |
Series | v2 of libdiagnostics | |
Message
David Malcolm
Nov. 21, 2023, 10:20 p.m. UTC
Here's v2 of the "libdiagnostics" shared library idea; see: https://gcc.gnu.org/wiki/libdiagnostics As in v1, patch 1 (for GCC) shows libdiagnostic.h (the public header file), along with examples of simple self-contained programs that show various uses of the API. As in v1, patch 2 (for GCC) is the work-in-progress implementation. Patch 3 (for GCC) adds a new libdiagnostics++.h, a wrapper API providing some syntactic sugar when using the API from C++. I've been using this to "eat my own dogfood" and write a simple SARIF-dumping tool: https://github.com/davidmalcolm/libdiagnostics-sarif-dump Patch 4 (for GCC) is an internal change needed by patch 1. Patch 5 (for GCC) updates GCC's source printing code so that when there's no column information, we don't print annotation lines. This fixes the extra lines seen using it from gas discussed in: https://gcc.gnu.org/pipermail/gcc-patches/2023-November/635575.html Patch 6 (for binutils) is an updated version of the experiment at using the API from gas. Thoughts? David Malcolm (5): libdiagnostics v2: header and examples libdiagnostics v2: work-in-progress implementation libdiagnostics v2: add C++ wrapper API diagnostics: add diagnostic_context::get_location_text diagnostics: don't print annotation lines when there's no column info gcc/Makefile.in | 131 +- gcc/configure | 2 +- gcc/configure.ac | 2 +- gcc/diagnostic-show-locus.cc | 26 +- gcc/diagnostic.cc | 35 +- gcc/diagnostic.h | 2 + gcc/libdiagnostics++.h | 378 +++++ gcc/libdiagnostics.cc | 1306 +++++++++++++++++ gcc/libdiagnostics.h | 602 ++++++++ gcc/libdiagnostics.map | 63 + .../libdiagnostics.dg/libdiagnostics.exp | 544 +++++++ gcc/testsuite/libdiagnostics.dg/test-dump.c | 55 + .../libdiagnostics.dg/test-error-with-note.c | 57 + .../libdiagnostics.dg/test-error-with-note.cc | 47 + gcc/testsuite/libdiagnostics.dg/test-error.c | 49 + gcc/testsuite/libdiagnostics.dg/test-error.cc | 40 + .../libdiagnostics.dg/test-fix-it-hint.c | 49 + .../libdiagnostics.dg/test-fix-it-hint.cc | 44 + .../libdiagnostics.dg/test-helpers++.h | 28 + .../libdiagnostics.dg/test-helpers.h | 29 + .../libdiagnostics.dg/test-labelled-ranges.c | 52 + .../libdiagnostics.dg/test-labelled-ranges.cc | 43 + .../libdiagnostics.dg/test-logical-location.c | 60 + .../libdiagnostics.dg/test-metadata.c | 54 + .../libdiagnostics.dg/test-multiple-lines.c | 61 + .../libdiagnostics.dg/test-no-column.c | 41 + .../test-note-with-fix-it-hint.c | 52 + .../test-text-sink-options.c | 46 + .../libdiagnostics.dg/test-warning.c | 52 + .../test-write-sarif-to-file.c | 46 + .../test-write-text-to-file.c | 47 + 31 files changed, 4018 insertions(+), 25 deletions(-) create mode 100644 gcc/libdiagnostics++.h create mode 100644 gcc/libdiagnostics.cc create mode 100644 gcc/libdiagnostics.h create mode 100644 gcc/libdiagnostics.map create mode 100644 gcc/testsuite/libdiagnostics.dg/libdiagnostics.exp create mode 100644 gcc/testsuite/libdiagnostics.dg/test-dump.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-error-with-note.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-error-with-note.cc create mode 100644 gcc/testsuite/libdiagnostics.dg/test-error.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-error.cc create mode 100644 gcc/testsuite/libdiagnostics.dg/test-fix-it-hint.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-fix-it-hint.cc create mode 100644 gcc/testsuite/libdiagnostics.dg/test-helpers++.h create mode 100644 gcc/testsuite/libdiagnostics.dg/test-helpers.h create mode 100644 gcc/testsuite/libdiagnostics.dg/test-labelled-ranges.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-labelled-ranges.cc create mode 100644 gcc/testsuite/libdiagnostics.dg/test-logical-location.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-metadata.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-multiple-lines.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-no-column.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-note-with-fix-it-hint.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-text-sink-options.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-warning.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-write-sarif-to-file.c create mode 100644 gcc/testsuite/libdiagnostics.dg/test-write-text-to-file.c
Comments
Thank you for your efforts. Having the wiki page to track this definitely is useful! I'll have a look at the "real patch" later, likely next week. But for patch 4+5 which look quite clean: can we get an early improvement and inclusion into GCC for those? They only adjust internals and should be well covered by the existing test suite, so we may be able to inspect the other changes from this patchset "alone". Kind Regards, Simon Am 21.11.2023 um 23:20 schrieb David Malcolm: > Here's v2 of the "libdiagnostics" shared library idea; see: > https://gcc.gnu.org/wiki/libdiagnostics > > As in v1, patch 1 (for GCC) shows libdiagnostic.h (the public > header file), along with examples of simple self-contained programs that > show various uses of the API. > > As in v1, patch 2 (for GCC) is the work-in-progress implementation. > > Patch 3 (for GCC) adds a new libdiagnostics++.h, a wrapper API providing > some syntactic sugar when using the API from C++. I've been using this > to "eat my own dogfood" and write a simple SARIF-dumping tool: > https://github.com/davidmalcolm/libdiagnostics-sarif-dump > > Patch 4 (for GCC) is an internal change needed by patch 1. > > Patch 5 (for GCC) updates GCC's source printing code so that when > there's no column information, we don't print annotation lines. This > fixes the extra lines seen using it from gas discussed in: > https://gcc.gnu.org/pipermail/gcc-patches/2023-November/635575.html > > Patch 6 (for binutils) is an updated version of the experiment at using > the API from gas. > > Thoughts? > > David Malcolm (5): > libdiagnostics v2: header and examples > libdiagnostics v2: work-in-progress implementation > libdiagnostics v2: add C++ wrapper API > diagnostics: add diagnostic_context::get_location_text > diagnostics: don't print annotation lines when there's no column info > > gcc/Makefile.in | 131 +- > gcc/configure | 2 +- > gcc/configure.ac | 2 +- > gcc/diagnostic-show-locus.cc | 26 +- > gcc/diagnostic.cc | 35 +- > gcc/diagnostic.h | 2 + > gcc/libdiagnostics++.h | 378 +++++ > gcc/libdiagnostics.cc | 1306 +++++++++++++++++ > gcc/libdiagnostics.h | 602 ++++++++ > gcc/libdiagnostics.map | 63 + > .../libdiagnostics.dg/libdiagnostics.exp | 544 +++++++ > gcc/testsuite/libdiagnostics.dg/test-dump.c | 55 + > .../libdiagnostics.dg/test-error-with-note.c | 57 + > .../libdiagnostics.dg/test-error-with-note.cc | 47 + > gcc/testsuite/libdiagnostics.dg/test-error.c | 49 + > gcc/testsuite/libdiagnostics.dg/test-error.cc | 40 + > .../libdiagnostics.dg/test-fix-it-hint.c | 49 + > .../libdiagnostics.dg/test-fix-it-hint.cc | 44 + > .../libdiagnostics.dg/test-helpers++.h | 28 + > .../libdiagnostics.dg/test-helpers.h | 29 + > .../libdiagnostics.dg/test-labelled-ranges.c | 52 + > .../libdiagnostics.dg/test-labelled-ranges.cc | 43 + > .../libdiagnostics.dg/test-logical-location.c | 60 + > .../libdiagnostics.dg/test-metadata.c | 54 + > .../libdiagnostics.dg/test-multiple-lines.c | 61 + > .../libdiagnostics.dg/test-no-column.c | 41 + > .../test-note-with-fix-it-hint.c | 52 + > .../test-text-sink-options.c | 46 + > .../libdiagnostics.dg/test-warning.c | 52 + > .../test-write-sarif-to-file.c | 46 + > .../test-write-text-to-file.c | 47 + > 31 files changed, 4018 insertions(+), 25 deletions(-) > create mode 100644 gcc/libdiagnostics++.h > create mode 100644 gcc/libdiagnostics.cc > create mode 100644 gcc/libdiagnostics.h > create mode 100644 gcc/libdiagnostics.map > create mode 100644 gcc/testsuite/libdiagnostics.dg/libdiagnostics.exp > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-dump.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-error-with-note.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-error-with-note.cc > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-error.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-error.cc > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-fix-it-hint.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-fix-it-hint.cc > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-helpers++.h > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-helpers.h > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-labelled-ranges.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-labelled-ranges.cc > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-logical-location.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-metadata.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-multiple-lines.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-no-column.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-note-with-fix-it-hint.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-text-sink-options.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-warning.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-write-sarif-to-file.c > create mode 100644 gcc/testsuite/libdiagnostics.dg/test-write-text-to-file.c >
On 21.11.2023 23:20, David Malcolm wrote: > @@ -101,6 +109,29 @@ had_warnings (void) > return warning_count; > } > > +#if USE_LIBDIAGNOSTICS > +static diagnostic_manager *diag_mgr; > +#endif > + > +void messages_init (void) > +{ > +#if USE_LIBDIAGNOSTICS > + diag_mgr = diagnostic_manager_new (); > + diagnostic_manager_add_text_sink (diag_mgr, stderr, > + DIAGNOSTIC_COLORIZE_IF_TTY); Coloring will want to be possible to turn off (or maybe be off by default, and be possible to turn on). As to the #if-s: I think they all would better be #ifdef. > @@ -182,6 +213,20 @@ as_warn_internal (const char *file, unsigned int line, char *buffer) > context = true; > } > > +#if USE_LIBDIAGNOSTICS > + const diagnostic_file *file_obj > + = diagnostic_manager_new_file (diag_mgr, file, NULL); > + > + const diagnostic_physical_location *loc > + = diagnostic_manager_new_location_from_file_and_line (diag_mgr, > + file_obj, > + line); > + > + diagnostic *d = diagnostic_begin (diag_mgr, > + DIAGNOSTIC_LEVEL_WARNING); > + diagnostic_set_location (d, loc); > + diagnostic_finish (d, "%s", buffer); > +#else This looks identical to ... > @@ -256,6 +302,19 @@ as_bad_internal (const char *file, unsigned int line, char *buffer) > context = true; > } > > +#if USE_LIBDIAGNOSTICS > + const diagnostic_file *file_obj > + = diagnostic_manager_new_file (diag_mgr, file, NULL); > + const diagnostic_physical_location *loc > + = diagnostic_manager_new_location_from_file_and_line (diag_mgr, > + file_obj, > + line); > + > + diagnostic *d = diagnostic_begin (diag_mgr, > + DIAGNOSTIC_LEVEL_ERROR); > + diagnostic_set_location (d, loc); > + diagnostic_finish (d, "%s", buffer); > +#else ... this, except for the level used. Put into a helper function? Which would the further want using from as_info_where()? Jan
Hi David, On 2023-11-21 22:20, David Malcolm wrote: > Here's v2 of the "libdiagnostics" shared library idea; see: > https://gcc.gnu.org/wiki/libdiagnostics > > As in v1, patch 1 (for GCC) shows libdiagnostic.h (the public > header file), along with examples of simple self-contained programs that > show various uses of the API. > > As in v1, patch 2 (for GCC) is the work-in-progress implementation. > > Patch 3 (for GCC) adds a new libdiagnostics++.h, a wrapper API providing > some syntactic sugar when using the API from C++. I've been using this > to "eat my own dogfood" and write a simple SARIF-dumping tool: > https://github.com/davidmalcolm/libdiagnostics-sarif-dump > > Patch 4 (for GCC) is an internal change needed by patch 1. > > Patch 5 (for GCC) updates GCC's source printing code so that when > there's no column information, we don't print annotation lines. This > fixes the extra lines seen using it from gas discussed in: > https://gcc.gnu.org/pipermail/gcc-patches/2023-November/635575.html > > Patch 6 (for binutils) is an updated version of the experiment at using > the API from gas. > > Thoughts? Do you have plans on making this a top level library instead? That would allow easily making it a non-optional dependency for binutils, as we could have the library in the binutils-gdb repo as well, for instance. From the Cauldron discussion I understood that the diagnostics stuff doesn't depend on much of GCC's data structures, and doesn't rely on the garbage collector. Is there something preventing that? (Other than "it's-a-matter-of-time/effort", of course.) Pedro Alves
On Tue, 2023-11-21 at 17:20 -0500, David Malcolm wrote: > gcc/ChangeLog: > * diagnostic-show-locus.cc > (layout::maybe_add_location_range): > Don't print annotation lines for ranges when there's no > column > info. > (selftest::test_one_liner_no_column): New. > (selftest::test_diagnostic_show_locus_one_liner): Call it. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Not a bugfix, but low-risk and useful for libdiagnostics, so I've taken the liberty of pushing this to gcc trunk as r14-5896-g5099525bff4f7c. Dave
Hi David - and thanks for posting an outline for libdiagnostics at https://gcc.gnu.org/wiki/libdiagnostics Currently this shows both libdiagnosts and libdiagnostics-sarif-dump integrated into GCC. Is this the plan or would those be available as a top-level project (the program as an example for the library), possibly with the library sources also pushed to GCC? Oh, and one question as I stumbled over that today: Would libdiagnostics now (or in the future) use libtextstyle for formatting (and another possible sink: HTML)? Simon Am 23.11.2023 um 18:36 schrieb Pedro Alves: > Hi David, > > On 2023-11-21 22:20, David Malcolm wrote: >> Here's v2 of the "libdiagnostics" shared library idea; see: >> https://gcc.gnu.org/wiki/libdiagnostics >> >> As in v1, patch 1 (for GCC) shows libdiagnostic.h (the public >> header file), along with examples of simple self-contained programs that >> show various uses of the API. >> >> As in v1, patch 2 (for GCC) is the work-in-progress implementation. >> >> Patch 3 (for GCC) adds a new libdiagnostics++.h, a wrapper API providing >> some syntactic sugar when using the API from C++. I've been using this >> to "eat my own dogfood" and write a simple SARIF-dumping tool: >> https://github.com/davidmalcolm/libdiagnostics-sarif-dump >> >> Patch 4 (for GCC) is an internal change needed by patch 1. >> >> Patch 5 (for GCC) updates GCC's source printing code so that when >> there's no column information, we don't print annotation lines. This >> fixes the extra lines seen using it from gas discussed in: >> https://gcc.gnu.org/pipermail/gcc-patches/2023-November/635575.html >> >> Patch 6 (for binutils) is an updated version of the experiment at using >> the API from gas. >> >> Thoughts? > > Do you have plans on making this a top level library instead? That would allow easily > making it a non-optional dependency for binutils, as we could have the library in > the binutils-gdb repo as well, for instance. From the Cauldron discussion I understood that > the diagnostics stuff doesn't depend on much of GCC's data structures, and doesn't rely on > the garbage collector. Is there something preventing that? (Other than "it's-a-matter-of-time/effort", > of course.) > > Pedro Alves > >