From patchwork Fri Nov 12 17:39:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dodji Seketeli X-Patchwork-Id: 47547 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 D3CE4385800F for ; Fri, 12 Nov 2021 17:42:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3CE4385800F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1636738958; bh=Pqvc5dhW8zrNSfXKnRa2Dk5guQvn8+TOs5XiceTP2Mk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=EyZ/0ys3Fek7JwR8NPY3pSWa6gCUqteyt9N32w4eO37ZqYlGL3rcEuXEcnQ7Ui4OT 4yejEaz1vOtuDz+f5qDNw43T8QDCmTXpdfOa43GMzbdULr2lfq5wbWvkcADuPU5wQV wy36jhUBwszX06Z8HdY3CIsifdgF/e10E6+OLy7Y= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org 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 2E0593858022 for ; Fri, 12 Nov 2021 17:39:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E0593858022 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-278-0gpAhe3RNuqpt5C4261P-A-1; Fri, 12 Nov 2021 12:39:47 -0500 X-MC-Unique: 0gpAhe3RNuqpt5C4261P-A-1 Received: by mail-qv1-f70.google.com with SMTP id g12-20020a0562141ccc00b003c0322ea7b6so3187079qvd.19 for ; Fri, 12 Nov 2021 09:39:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=Pqvc5dhW8zrNSfXKnRa2Dk5guQvn8+TOs5XiceTP2Mk=; b=uYjFdaIsYVd5bYQwwWlqwFIUN4t9mbWizUiBywTHizePi+jb+WvGE8WR+FjFNC6eMz Mz8udh/7SPqKAMI5GXVDIckFuBIMVlaxIaemaiBzfksrIvtaZ5I9WfNIzL55qt91iCQD oZnKxwlDollKzSZB2zB6AlUTWS2USlom1hsV0fl+n2hlbXGesZi5/9kbQDVk3R/FHTNi ygV3K2L1jTSjbMdR+d9zDWSSruaDhLe63GbOlgD5vSGmN5dapyQSO+LYZe6YAqDUgZGv kSTPjIAGB6HZzajhMN60/Fwjnz7OEsMlzqT0jT0FFZBLoHKpjZa85QliMuOvYRuMjGYs USIA== X-Gm-Message-State: AOAM530xykIWV9WiwRVLI8Tj5TyQKlmsV5iC26j6Y+O7Dl8cKWS1cAeQ 3YfG0HWxabPnTFxrtKvC7+ic4nc1zgbq22BLBzITDePI6oYvCgjJswtw/BJb2oF9HAkoDxSWnsc o+pkeOBpJJEOpNrF5eGv54gJOPB0Yvny+uK6W3nZ9Z5V9SDdVazD6AZteOEBe/REcLWc6 X-Received: by 2002:ad4:4d05:: with SMTP id l5mr15930000qvl.54.1636738787032; Fri, 12 Nov 2021 09:39:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxKxPWHUqQGqP9S6JWYO0LJgEjaU9VGnPesFW1Fu855fVBY0bQyEH0VPyi6c5LwtSahNs3YJw== X-Received: by 2002:ad4:4d05:: with SMTP id l5mr15929963qvl.54.1636738786596; Fri, 12 Nov 2021 09:39:46 -0800 (PST) Received: from localhost ([88.120.130.27]) by smtp.gmail.com with ESMTPSA id w11sm3689228qta.50.2021.11.12.09.39.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Nov 2021 09:39:45 -0800 (PST) Received: by localhost (Postfix, from userid 1000) id 5C9B9581C23; Fri, 12 Nov 2021 18:39:44 +0100 (CET) To: libabigail@sourceware.org Subject: [PATCH, applied] abidw: Add --abixml-version Organization: Red Hat / France X-Operating-System: Fedora 36 X-URL: http://www.redhat.com Date: Fri, 12 Nov 2021 18:39:44 +0100 Message-ID: <87bl2p6zof.fsf@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.4 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_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Dodji Seketeli via Libabigail From: Dodji Seketeli Reply-To: Dodji Seketeli Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" Hello, This patch adds a command line option to display the version number of the ABIXML output format. * doc/manuals/abidw.rst: Document the --abixml-version command line option. * configure.ac (ABIXML_VERSION_MAJOR, ABIXML_VERSION_MINOR): Define these two new autoconf variables. * include/abg-config.h (abigail_get_abixml_version): Declare new function. * include/abg-tools-utils.h (get_abixml_version_string): Declare new function. * include/abg-version.h.in (ABIGAIL_ABIXML_VERSION_MAJOR) (ABIGAIL_ABIXML_VERSION_MINOR): Define new preprocessor macros. * src/abg-config.cc (config::config): Initialize config::m_format_{minor,major} using the newly defined preprocessor macros ABIGAIL_ABIXML_VERSION_M{IN,AJ}OR. * src/abg-tools-utils.cc (get_abixml_version_string): Define new function. * tools/abidw.cc (options::display_abixml_version): Define new data member. (options::options): Initialize it. (display_usage): Emit a help string for the new --abixml-version option. (parse_command_line): Parse the --abixml-version string. (main): Emit the abixml version when asked. Signed-off-by: Dodji Seketeli Applied to the master branch. --- configure.ac | 4 ++++ doc/manuals/abidw.rst | 14 +++++++++----- include/abg-config.h | 3 +++ include/abg-tools-utils.h | 1 + include/abg-version.h.in | 2 ++ src/abg-config.cc | 17 +++++++++++++++-- src/abg-tools-utils.cc | 12 ++++++++++++ tools/abidw.cc | 17 ++++++++++++++++- 8 files changed, 62 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index 4f835d07..5342a269 100644 --- a/configure.ac +++ b/configure.ac @@ -38,10 +38,14 @@ AM_SILENT_RULES([yes]) VERSION_MAJOR=version_major VERSION_MINOR=version_minor VERSION_REVISION=0 +ABIXML_VERSION_MAJOR=2 +ABIXML_VERSION_MINOR=1 AC_SUBST(VERSION_MAJOR) AC_SUBST(VERSION_MINOR) AC_SUBST(VERSION_REVISION) +AC_SUBST(ABIXML_VERSION_MAJOR) +AC_SUBST(ABIXML_VERSION_MINOR) dnl This VERSION_SUFFIX environment variable is to allow appending dnl arbitrary text to the libabigail version string representation. diff --git a/doc/manuals/abidw.rst b/doc/manuals/abidw.rst index d7545899..fe4aafd8 100644 --- a/doc/manuals/abidw.rst +++ b/doc/manuals/abidw.rst @@ -5,11 +5,11 @@ abidw abidw reads a shared library in `ELF`_ format and emits an XML representation of its ABI to standard output. The emitted -representation includes all the globally defined functions and -variables, along with a complete representation of their types. It -also includes a representation of the globally defined ELF symbols of -the file. The input shared library must contain associated debug -information in `DWARF`_ format. +representation format, named ``ABIXML``, includes all the globally +defined functions and variables, along with a complete representation +of their types. It also includes a representation of the globally +defined ELF symbols of the file. The input shared library must +contain associated debug information in `DWARF`_ format. When given the ``--linux-tree`` option, this program can also handle a Linux kernel tree. That is, a directory tree that contains both the @@ -39,6 +39,10 @@ Options Display the version of the program and exit. + * `--abixml-version` + + Display the version of the ABIXML format emitted by this program and exit. + * ``--debug-info-dir | -d`` <*dir-path*> In cases where the debug info for *path-to-elf-file* is in a diff --git a/include/abg-config.h b/include/abg-config.h index f16f05be..4d94c71c 100644 --- a/include/abg-config.h +++ b/include/abg-config.h @@ -72,6 +72,9 @@ extern "C" std::string& min, std::string& rev, std::string& suf); + + void + abigail_get_abixml_version(std::string& maj, std::string& min); } }//end namespace abigail diff --git a/include/abg-tools-utils.h b/include/abg-tools-utils.h index ba09f30f..68e54028 100644 --- a/include/abg-tools-utils.h +++ b/include/abg-tools-utils.h @@ -61,6 +61,7 @@ bool split_string(const string&, const string&, vector&); bool string_suffix(const string&, const string&, string&); bool sorted_strings_common_prefix(vector&, string&); string get_library_version_string(); +string get_abixml_version_string(); bool execute_command_and_get_output(const string&, vector&); bool get_dsos_provided_by_rpm(const string& rpm_path, set& provided_dsos); diff --git a/include/abg-version.h.in b/include/abg-version.h.in index dc7531a1..939f0cd5 100644 --- a/include/abg-version.h.in +++ b/include/abg-version.h.in @@ -5,4 +5,6 @@ #define ABIGAIL_VERSION_MINOR "@VERSION_MINOR@" #define ABIGAIL_VERSION_REVISION "@VERSION_REVISION@" #define ABIGAIL_VERSION_SUFFIX "@VERSION_SUFFIX@" +#define ABIGAIL_ABIXML_VERSION_MAJOR "@ABIXML_VERSION_MAJOR@" +#define ABIGAIL_ABIXML_VERSION_MINOR "@ABIXML_VERSION_MINOR@" #endif diff --git a/src/abg-config.cc b/src/abg-config.cc index 7d65e2ba..d2e15737 100644 --- a/src/abg-config.cc +++ b/src/abg-config.cc @@ -18,8 +18,8 @@ ABG_END_EXPORT_DECLARATIONS namespace abigail { config::config() - : m_format_minor("1"), - m_format_major("2"), + : m_format_minor(ABIGAIL_ABIXML_VERSION_MINOR), + m_format_major(ABIGAIL_ABIXML_VERSION_MAJOR), m_xml_element_indent(2), m_tu_instr_suffix(".bi"), m_tu_instr_archive_suffix(".abi") @@ -80,5 +80,18 @@ abigail_get_library_version(std::string& major, suffix = ABIGAIL_VERSION_SUFFIX; } +/// Return the version numbers for the ABIXML format. +/// +/// @param maj the major version number of the ABIXML format. +/// +/// @param min the minor version number of the ABIXML format. +void +abigail_get_abixml_version(std::string& major, + std::string& minor) +{ + major = ABIGAIL_ABIXML_VERSION_MAJOR; + minor = ABIGAIL_ABIXML_VERSION_MINOR; +} + } }//end namespace abigail diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc index cd8fe468..e3e53fbc 100644 --- a/src/abg-tools-utils.cc +++ b/src/abg-tools-utils.cc @@ -1037,6 +1037,18 @@ get_library_version_string() return version_string; } +/// Return the version string for the ABIXML format. +/// +/// @return the version string of the ABIXML format. +string +get_abixml_version_string() +{ + string major, minor, version_string; + abigail::abigail_get_abixml_version(major, minor); + version_string = major + "." + minor; + return version_string; +} + /// Execute a shell command and returns its output. /// /// @param cmd the shell command to execute. diff --git a/tools/abidw.cc b/tools/abidw.cc index 240ed095..03f76e29 100644 --- a/tools/abidw.cc +++ b/tools/abidw.cc @@ -84,6 +84,7 @@ struct options vector kabi_whitelist_paths; suppressions_type kabi_whitelist_supprs; bool display_version; + bool display_abixml_version; bool check_alt_debug_info_path; bool show_base_name_alt_debug_info_path; bool write_architecture; @@ -117,6 +118,7 @@ struct options options() : display_version(), + display_abixml_version(), check_alt_debug_info_path(), show_base_name_alt_debug_info_path(), write_architecture(true), @@ -165,6 +167,7 @@ display_usage(const string& prog_name, ostream& out) << " where options can be: \n" << " --help|-h display this message\n" << " --version|-v display program version information and exit\n" + << " --abixml-version display the version of the ABIXML ABI format\n" << " --debug-info-dir|-d look for debug info under 'dir-path'\n" << " --headers-dir|--hd the path to headers of the elf file\n" << " --header-file|--hf the path one header of the elf file\n" @@ -229,6 +232,9 @@ parse_command_line(int argc, char* argv[], options& opts) else if (!strcmp(argv[i], "--version") || !strcmp(argv[i], "-v")) opts.display_version = true; + else if (!strcmp(argv[i], "--abixml-version") + || !strcmp(argv[i], "-v")) + opts.display_abixml_version = true; else if (!strcmp(argv[i], "--debug-info-dir") || !strcmp(argv[i], "-d")) { @@ -817,7 +823,8 @@ main(int argc, char* argv[]) if (!parse_command_line(argc, argv, opts) || (opts.in_file_path.empty() - && !opts.display_version)) + && !opts.display_version + && !opts.display_abixml_version)) { if (!opts.wrong_option.empty()) emit_prefix(argv[0], cerr) @@ -834,6 +841,14 @@ main(int argc, char* argv[]) return 0; } + if (opts.display_abixml_version) + { + emit_prefix(argv[0], cout) + << abigail::tools_utils::get_abixml_version_string() + << "\n"; + return 0; + } + ABG_ASSERT(!opts.in_file_path.empty()); if (opts.corpus_group_for_linux) {