MCPcopy Create free account
hub / github.com/F-Stack/f-stack / parse_pmdinfo

Function parse_pmdinfo

dpdk/usertools/dpdk-pmdinfo.py:109–140  ·  view source on GitHub ↗

Extract DPDK PMD info JSON strings from an ELF file. :returns: A list of DPDK drivers info dictionaries.

(paths: Iterable[Path], search_plugins: bool)

Source from the content-addressed store, hash-verified

107
108# ----------------------------------------------------------------------------
109def parse_pmdinfo(paths: Iterable[Path], search_plugins: bool) -> List[dict]:
110 """
111 Extract DPDK PMD info JSON strings from an ELF file.
112
113 :returns:
114 A list of DPDK drivers info dictionaries.
115 """
116 binaries = set(paths)
117 for p in paths:
118 binaries.update(get_needed_libs(p))
119 if search_plugins:
120 # cast to list to avoid errors with update while iterating
121 binaries.update(list(get_plugin_libs(binaries)))
122
123 drivers = []
124
125 for b in binaries:
126 logging.debug("analyzing %s", b)
127 try:
128 for s in get_elf_strings(b, ".rodata", "PMD_INFO_STRING="):
129 try:
130 info = json.loads(s)
131 scrub_pci_ids(info)
132 drivers.append(info)
133 except ValueError as e:
134 # invalid JSON, should never happen
135 logging.warning("%s: %s", b, e)
136 except ELFError as e:
137 # only happens for discovered plugins that are not ELF
138 logging.debug("%s: cannot parse ELF: %s", b, e)
139
140 return drivers
141
142
143# ----------------------------------------------------------------------------

Callers 1

mainFunction · 0.85

Calls 7

get_needed_libsFunction · 0.85
get_plugin_libsFunction · 0.85
get_elf_stringsFunction · 0.85
scrub_pci_idsFunction · 0.85
updateMethod · 0.80
setFunction · 0.50
listClass · 0.50

Tested by

no test coverage detected