Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cmdebug/svd_gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import math
import sys
import struct
import pkg_resources
import importlib_resources

sys.path.append('.')
from cmdebug.svd import SVDFile
Expand All @@ -40,10 +40,10 @@ class LoadSVD(gdb.Command):
def __init__(self):
self.vendors = {}
try:
vendor_names = pkg_resources.resource_listdir("cmsis_svd", "data")
for vendor in vendor_names:
fnames = pkg_resources.resource_listdir("cmsis_svd", "data/{}".format(vendor))
self.vendors[vendor] = [fname for fname in fnames if fname.lower().endswith(".svd")]
for vendor_path in importlib_resources.files("cmsis_svd.data").iterdir():
vendor =vendor_path.name
files = importlib_resources.files(f"cmsis_svd.data.{vendor}").iterdir()
self.vendors[vendor] = [file.name for file in files if file.name.lower().endswith(".svd")]
except:
pass

Expand Down Expand Up @@ -80,7 +80,7 @@ def invoke(args, from_tty):
f = args[0]
elif argc == 2:
gdb.write("Loading SVD file {}/{}...\n".format(args[0], args[1]))
f = pkg_resources.resource_filename("cmsis_svd", "data/{}/{}".format(args[0], args[1]))
f = str(importlib_resources.files("cmsis_svd.data") / f"{args[0]}" / f"{args[1]}")
else:
raise gdb.GdbError("Usage: svd_load <vendor> <device.svd> or svd_load <path/to/filename.svd>\n")
try:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
keywords='arm gdb cortex cortex-m svd trace microcontroller',
license='GPL',
install_requires=[
'setuptools',
'importlib-resources',
'lxml',
],
)