DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
To: thomas@monjalon.net
Cc: dev@dpdk.org, Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
Subject: [dpdk-dev]  [PATCH] devtools: add script to verify map files
Date: Mon, 12 Feb 2018 21:43:12 +0530	[thread overview]
Message-ID: <20180212161312.31795-1-pbhagavatula@caviumnetworks.com> (raw)

This script checks for the symbols specified in the map files against
the symbols present in the map file directory.
Currently, the script checks for map files in drivers and lib directory.

Example:
./devtools/check-map.py

The following symbols are unused :

Map file : /home/pavan/Work/clean/dpdk/drivers/mempool/dpaa/...
['rte_dpaa_pool_table']

Map file : /home/pavan/Work/clean/dpdk/drivers/bus/fslmc/...
['qbman_get_version', 'qbman_swp_send_multiple']

...

Signed-off-by: Pavan Nikhilesh <pbhagavatula@caviumnetworks.com>
---
 devtools/check-map.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100755 devtools/check-map.py

diff --git a/devtools/check-map.py b/devtools/check-map.py
new file mode 100755
index 000000000..a508469d6
--- /dev/null
+++ b/devtools/check-map.py
@@ -0,0 +1,56 @@
+#! /usr/bin/env python
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2017 Cavium, Inc
+#
+
+import subprocess
+import re
+import os
+from glob import glob
+
+paths = ['drivers', 'lib']
+map_files = []
+
+for path in paths:
+    map_files = map_files + [y
+                             for x in os.walk(os.environ['PWD'] + '/' + path)
+                             for y in glob(os.path.join(x[0],
+                                                        '*.map'))]
+
+print("\nThe following symbols are unused : \n")
+for map_file in map_files:
+    path = os.path.dirname(os.path.abspath(map_file))
+    with open(map_file) as f:
+        map_content = [line.strip() for line in f]
+    # Filter empty lines.
+    map_content = list(filter(None, map_content))
+    regex = re.compile(
+            r"""
+            \bDPDK.*\b |
+            \bglobal.*\b |
+            \blocal.*\b | \}.* |
+            \bEXPERIMENTAL\b |
+            \bper_lcore.*\b""",
+            flags=re.I | re.X | re.VERBOSE)
+    filtered_map = filter(lambda i: not regex.search(i), map_content)
+    filtered_map = [i for i in map_content if not regex.search(i)]
+    filtered_map = [s.replace(';', '') for s in filtered_map]
+    # Filter out known lines.
+    if not filtered_map:
+        continue
+    not_found = []
+    # Gerp in the map file directory for each symbol
+    for map_symbol in filtered_map:
+        try:
+            op = subprocess.check_output(['grep', '-nr', '--exclude',
+                                          os.path.basename(map_file),
+                                          map_symbol,
+                                          path])
+        except subprocess.CalledProcessError as ex:
+            not_found.append(map_symbol)
+            rc = ex.returncode
+            if rc != 1:
+                raise
+    if not_found:
+        print("Map file : %s" % map_file)
+        print("%s\n" % not_found)
-- 
2.16.1

             reply	other threads:[~2018-02-12 16:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-12 16:13 Pavan Nikhilesh [this message]
2018-02-13 10:48 ` Ferruh Yigit
2018-05-27 20:50   ` Thomas Monjalon
2018-05-27 21:54     ` [dpdk-dev] [PATCH v2] devtools: check orphan symbols in " Thomas Monjalon
2018-05-29 15:56       ` Thomas Monjalon
2018-05-28  9:21     ` [dpdk-dev] [PATCH] devtools: add script to verify " Bruce Richardson
2018-05-28  9:31       ` Thomas Monjalon
2018-05-28 13:17         ` Bruce Richardson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180212161312.31795-1-pbhagavatula@caviumnetworks.com \
    --to=pbhagavatula@caviumnetworks.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).