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 3135D385840B for ; Wed, 5 Jun 2024 13:15:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3135D385840B 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 3135D385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717593337; cv=none; b=q64gFWKYmpO492naeGptt/BRxPPFHLWgQV6q5yvdOIQzdIsvOZQLEAXafI+vJWluSjTXV0GJbq7jxsH++zhs5xZYXEBBjprKvMI6Xlws7S/9W6qhVuoVT6CNmlzEsSjAC4OIGS5mpJQcNfdykbAwa+kcX4oQNavIp3Fk1CgXVOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1717593337; c=relaxed/simple; bh=LJvTef4P8L97Fp6lWe56J7XUitjP5WBhPRksM7XZ45Y=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=NKcHQaMbCbSKVLltTyArjlePIeseLBmrL5HLILpwC2x76KOuilRya9R4YmdVY7aq6eA9BoL7QGGEbwUyTgy8aHYC6+KcZd36naxJv21D6H0GGEMvpStqRONYgbZd5CL8TxWVH9MlKvZOA0txroaeKzRRMCH7jqEPgsSrJ6CdRW4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717593334; 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=NImr7P9dn7CHQauJIyqNLlQ2g1k9lFMr4vnyiimynls=; b=CmyKsSSEPaHbhy8xYcE7TqW7WlqSuN//1HJ8Y2Av0srnuVstkElf8vjVxsHNMrWHkx1+QQ /VNSVUd04G0FZtv0g7zPCJNEoXKRqhVio7tLvQC4rHy/eA7IBWBN38tyLOWoj3+ToHKVA3 wp7aC2/fDlvmpDkutv1nD5eO4tDFQW4= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-322-WX3DBRAlMsWnTn0XXpBSbw-1; Wed, 05 Jun 2024 09:15:29 -0400 X-MC-Unique: WX3DBRAlMsWnTn0XXpBSbw-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-35dc7e6e859so4323287f8f.2 for ; Wed, 05 Jun 2024 06:15:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717593327; x=1718198127; 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=NImr7P9dn7CHQauJIyqNLlQ2g1k9lFMr4vnyiimynls=; b=AeoZISXMVsmH/TeGGoMrZh8FqiOr//EJdxedX59fV1n6P6lBWWMEPKNTu21BKOM5VU QsTG17nKouSn3gGBSj92rWQ92hLiVXBOnbwL6fuyTDhIE+JX/H6GvfCLKDDGs0+HxyYe WrmoP5xLDpdkm4w+Cb0oejGZqZQyYr9a4Z544j15D7jyjLUJrmsTsHhKFY98H+rIftql nVJXxIrNsFd5n8KYTmT5xiKmm85p8N85RtQUIfmJrIY2rk6VI7xOH3T1xSTAS0vQDI6e svYM7DmpR4EmsieveBgif8eqkyF1hsIhU6G8v6MeKckg/8axVVhO1MgRRJQLWYYe+1+b s54A== X-Gm-Message-State: AOJu0Yxw7UhhQ56hAoa20+ts0cvxiFb3ngMmFFUmAGBc+LuC3pMmziql 2KIUCfUmgjv4lAYbuXYctYx1ZhyPpynlfh7uFdIBPSRCFwBmxR9qDGJ2VhqW5pHgFuMjdyzAaPQ QgxAoCAoMQM8W5XYKyJDR6eCy6iiBG8/4QSPhAoDrZMlQLxJ6dFL0S6BMYF3wVo0SKjmItI9nsn axwPX3APEEbNadJ6mnGRnRw7eYt3+Atv1FbEQW1NTPV6o= X-Received: by 2002:a5d:4248:0:b0:35b:1d7a:4866 with SMTP id ffacd0b85a97d-35e840494admr1890056f8f.10.1717593327028; Wed, 05 Jun 2024 06:15:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuiJNwFpSKp9P6ugFTFsM5W1XN/O2jo/7os/oXC6bXOj9Zf77usPqn1a52V3qdwgBM9/ywdQ== X-Received: by 2002:a5d:4248:0:b0:35b:1d7a:4866 with SMTP id ffacd0b85a97d-35e840494admr1890036f8f.10.1717593326542; Wed, 05 Jun 2024 06:15:26 -0700 (PDT) Received: from localhost ([31.111.84.186]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd064dfc6sm14499489f8f.92.2024.06.05.06.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 06:15:26 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 4/8] gdb: convert separate-debug-file to new(ish) debug scheme Date: Wed, 5 Jun 2024 14:15:11 +0100 Message-Id: <4efbb2060ea7298f855ee8141f7978ef1f142353.1717592684.git.aburgess@redhat.com> 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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_H4,RCVD_IN_MSPIKE_WL,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: Convert 'set/show debug separate-debug-file' to the new debug scheme. Though I'm not sure if we can really call it "new" any more! --- gdb/build-id.c | 38 +++++++++++++------------------------- gdb/symfile.c | 45 ++++++++++++++++----------------------------- gdb/symfile.h | 19 +++++++++++++++++++ 3 files changed, 48 insertions(+), 54 deletions(-) diff --git a/gdb/build-id.c b/gdb/build-id.c index fe0494ae54e..8ce94f1e7a0 100644 --- a/gdb/build-id.c +++ b/gdb/build-id.c @@ -81,11 +81,7 @@ static gdb_bfd_ref_ptr build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len, const bfd_byte *build_id) { - if (separate_debug_file_debug) - { - gdb_printf (gdb_stdlog, _(" Trying %s..."), link.c_str ()); - gdb_flush (gdb_stdlog); - } + separate_debug_file_debug_printf ("Trying %s...", link.c_str ()); /* lrealpath() is expensive even for the usually non-existent files. */ gdb::unique_xmalloc_ptr filename_holder; @@ -100,10 +96,7 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len, if (filename == NULL) { - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, - _(" no, unable to compute real path\n")); - + separate_debug_file_debug_printf ("unable to compute real path"); return {}; } @@ -112,23 +105,17 @@ build_id_to_debug_bfd_1 (const std::string &link, size_t build_id_len, if (debug_bfd == NULL) { - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, _(" no, unable to open.\n")); - + separate_debug_file_debug_printf ("unable to open."); return {}; } if (!build_id_verify (debug_bfd.get(), build_id_len, build_id)) { - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, _(" no, build-id does not match.\n")); - + separate_debug_file_debug_printf ("build-id does not match."); return {}; } - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, _(" yes!\n")); - + separate_debug_file_debug_printf ("found a match"); return debug_bfd; } @@ -140,6 +127,8 @@ static gdb_bfd_ref_ptr build_id_to_bfd_suffix (size_t build_id_len, const bfd_byte *build_id, const char *suffix) { + SEPARATE_DEBUG_FILE_SCOPED_DEBUG_ENTER_EXIT; + /* Keep backward compatibility so that DEBUG_FILE_DIRECTORY being "" will cause "/.build-id/..." lookups. */ @@ -223,10 +212,9 @@ find_separate_debug_file_by_buildid (struct objfile *objfile, build_id = build_id_bfd_get (objfile->obfd.get ()); if (build_id != NULL) { - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, - _("\nLooking for separate debug info (build-id) for " - "%s\n"), objfile_name (objfile)); + SEPARATE_DEBUG_FILE_SCOPED_DEBUG_START_END + ("looking for separate debug info (build-id) for %s", + objfile_name (objfile)); gdb_bfd_ref_ptr abfd (build_id_to_debug_bfd (build_id->size, build_id->data)); @@ -235,9 +223,9 @@ find_separate_debug_file_by_buildid (struct objfile *objfile, && filename_cmp (bfd_get_filename (abfd.get ()), objfile_name (objfile)) == 0) { - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, "\"%s\": separate debug info file has no " - "debug info", bfd_get_filename (abfd.get ())); + separate_debug_file_debug_printf + ("\"%s\": separate debug info file has no debug info", + bfd_get_filename (abfd.get ())); warnings->warn (_("\"%ps\": separate debug info file has no " "debug info"), styled_string (file_name_style.style (), diff --git a/gdb/symfile.c b/gdb/symfile.c index f7f5be5a39a..2cb1f652867 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -1229,6 +1229,8 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, struct objfile *parent_objfile, deferred_warnings *warnings) { + SEPARATE_DEBUG_FILE_SCOPED_DEBUG_ENTER_EXIT; + unsigned long file_crc; int file_crc_p; struct stat parent_stat, abfd_stat; @@ -1243,19 +1245,13 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, if (filename_cmp (name.c_str (), objfile_name (parent_objfile)) == 0) return 0; - if (separate_debug_file_debug) - { - gdb_printf (gdb_stdlog, _(" Trying %s..."), name.c_str ()); - gdb_flush (gdb_stdlog); - } + separate_debug_file_debug_printf ("Trying %s...", name.c_str ()); gdb_bfd_ref_ptr abfd (gdb_bfd_open (name.c_str (), gnutarget)); if (abfd == NULL) { - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, _(" no, unable to open.\n")); - + separate_debug_file_debug_printf ("unable to open file"); return 0; } @@ -1277,10 +1273,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, if (abfd_stat.st_dev == parent_stat.st_dev && abfd_stat.st_ino == parent_stat.st_ino) { - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, - _(" no, same file as the objfile.\n")); - + separate_debug_file_debug_printf ("same file as the objfile"); return 0; } verified_as_different = 1; @@ -1292,9 +1285,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, if (!file_crc_p) { - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, _(" no, error computing CRC.\n")); - + separate_debug_file_debug_printf ("error computing CRC"); return 0; } @@ -1310,20 +1301,18 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, { if (!gdb_bfd_crc (parent_objfile->obfd.get (), &parent_crc)) { - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, - _(" no, error computing CRC.\n")); - + separate_debug_file_debug_printf ("error computing CRC"); return 0; } } if (verified_as_different || parent_crc != file_crc) { - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, "the debug information found in \"%s\"" - " does not match \"%s\" (CRC mismatch).\n", - name.c_str (), objfile_name (parent_objfile)); + separate_debug_file_debug_printf + ("the debug information found in \"%s\" does not match " + "\"%s\" (CRC mismatch).", name.c_str (), + objfile_name (parent_objfile)); + warnings->warn (_("the debug information found in \"%ps\"" " does not match \"%ps\" (CRC mismatch)."), styled_string (file_name_style.style (), @@ -1335,8 +1324,7 @@ separate_debug_file_exists (const std::string &name, unsigned long crc, return 0; } - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, _(" yes!\n")); + separate_debug_file_debug_printf ("found a match"); return 1; } @@ -1377,10 +1365,9 @@ find_separate_debug_file (const char *dir, unsigned long crc32, struct objfile *objfile, deferred_warnings *warnings) { - if (separate_debug_file_debug) - gdb_printf (gdb_stdlog, - _("\nLooking for separate debug info (debug link) for " - "%s\n"), objfile_name (objfile)); + SEPARATE_DEBUG_FILE_SCOPED_DEBUG_START_END + ("looking for separate debug info (debug link) for %s", + objfile_name (objfile)); /* First try in the same directory as the original file. */ std::string debugfile = dir; diff --git a/gdb/symfile.h b/gdb/symfile.h index a5b0c91469c..508ba48d161 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -371,6 +371,25 @@ extern gdb_bfd_ref_ptr find_separate_debug_file_in_section (struct objfile *); extern bool separate_debug_file_debug; +/* Print a "separate-debug-file" debug statement. */ + +#define separate_debug_file_debug_printf(fmt, ...) \ + debug_prefixed_printf_cond (separate_debug_file_debug, \ + "separate-debug-file", \ + fmt, ##__VA_ARGS__) + +/* Print "separate-debug-file" enter/exit debug statements. */ + +#define SEPARATE_DEBUG_FILE_SCOPED_DEBUG_ENTER_EXIT \ + scoped_debug_enter_exit (separate_debug_file_debug, \ + "separate-debug-file") + +/* Print "separate-debug-file" start/end debug statements. */ + +#define SEPARATE_DEBUG_FILE_SCOPED_DEBUG_START_END(fmt, ...) \ + scoped_debug_start_end (separate_debug_file_debug, \ + "separate-debug-file", fmt, ##__VA_ARGS__) + /* Read full symbols immediately. */ extern int readnow_symbol_files; -- 2.25.4