You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[x ] PlatformIO Core.
If you’ve found a bug, please provide an information below.
Configuration
Operating system:
Windows 11 Version 23H2(OS Build 22631)
PlatformIO Version (platformio --version):
PlatformIO Core, version 6.1.16
Description of problem
When trying to use the Project Inspector for Memory Analysis with binaries with a non-native GCC or non-GCC based compilers an Assertion Error is thrown and the Memory Analysis is not available.
Actual Results
COMPILER LOCATION: Compiler set through project option: D:\uti\TI\ARM\4.0.0.LTS
CONFIGURATION: https://docs.platformio.org/page/boards/timspm0/lp-mspm0g3507.html
PLATFORM: Texas Instruments MSPM0 (0.0.0) > TI Launchpad MSPM0G3507
HARDWARE: 80MHz, 31.25KB RAM, 125KB Flash
DEBUG: Current (openocd_mspm0) On-board (openocd_mspm0) External (jlink)
PACKAGES:
openocd_mspm0 @ 1.0.0
tool-jlink @ 1.78811.0 (7.88.11)
toolchain-gccarmnoneeabi @ 1.90301.200702 (9.3.1)
[...]
Generating memory usage report...
*** [sizedata] AssertionError :
Traceback (most recent call last):
File "C:\Users\user\.platformio\packages\tool-scons\scons-local-4.8.1\SCons\Action.py", line 1441, in execute
result = self.execfunction(target=target, source=rsources, env=env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.platformio\packages\tool-scons\scons-local-4.8.1\SCons\Util\envs.py", line 252, in call
return self.method(*nargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.platformio\penv\Lib\site-packages\platformio\builder\tools\piosize.py", line 227, in DumpSizeData
for symbol in _collect_symbols_info(env, elffile, elf_path, sections):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.platformio\penv\Lib\site-packages\platformio\builder\tools\piosize.py", line 138, in _collect_symbols_info
symbol_locations = _get_symbol_locations(env, elf_path, symbol_addrs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.platformio\penv\Lib\site-packages\platformio\builder\tools\piosize.py", line 54, in _get_symbol_locations
assert len(addrs) == len(locations)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
========================== [FAILED] Took 3.29 seconds =========================="
Expected Results
Successfully completed analysis with memory sizes and symbol display for using binaries with different compilers.
Additional info
Location of Issue:
The Assertion issue arises in the "piosize.py" Core file.
This happens in actually 2 functions, but "_get_symbol_locations()" is called first as seen above in error log:
1. _get_symbol_locations()
48: def _get_symbol_locations(env, elf_path, addrs):
49: if not addrs:
50: return {}
51: cmd = [env.subst("$CC").replace("-gcc", "-addr2line"), "-e", elf_path]
52: result = _run_tool(cmd, env, addrs)
53: locations = [line for line in result["out"].split("\n") if line]
54: assert len(addrs) == len(locations)
55:
56: return dict(zip(addrs, [loc.strip() for loc in locations]))
2. _get_demangled_names()
59: def _get_demangled_names(env, mangled_names):
60: if not mangled_names:
61: return {}
62: result = _run_tool(
63: [env.subst("$CC").replace("-gcc", "-c++filt")], env, mangled_names
64: )
65: demangled_names = [line for line in result["out"].split("\n") if line]
66: assert len(mangled_names) == len(demangled_names)
67:
68: return dict(
69: zip(
70: mangled_names,
71: [dn.strip().replace("::FUNCTION", "") for dn in demangled_names],
72: )
73: )
Before doing the assert check the issue already occurs in Line 51-52 and 62-63 in "piosize.py".
Here it is assumed that the compiler command options "-gcc", -"addr2line" and "-c++filt" are available to get the address and demangled name of a symbol.
When using non-native or non-GCC compilers those commands are not always available and throw an error when calling it via "run_tool".
Therefore the assertion len check is going to fail afterwards.
Suggested Fix:
Instead of using the GCC Compiler specific commands to extract the necessary information, they can also already be fetched from the compiled binaries that contain the debug data in the DWARF format.
Many other compilers than GCC support this format out-of-the-box.
The Project Inspector already utilizes the "pyelftools" library in its core which supports also the extraction of DWARF information.
By combining the DWARF and ELF information and map them it is possible to achive the same results and to be compiler independent.
I just wanted to get some consensus on this issue before attempting a pull request with a suggested fix in "piosize.py".
I think some other PIO users would be happy as well if more different compiler variants within the Project Inspector can be supported natively from the PIO Core. :)
I'll be happy to receive feedback from you how you see this issue.
The text was updated successfully, but these errors were encountered:
What kind of issue is this?
If you’ve found a bug, please provide an information below.
Configuration
Operating system:
Windows 11 Version 23H2(OS Build 22631)
PlatformIO Version (
platformio --version
):PlatformIO Core, version 6.1.16
Description of problem
When trying to use the Project Inspector for Memory Analysis with binaries with a non-native GCC or non-GCC based compilers an Assertion Error is thrown and the Memory Analysis is not available.
Actual Results
COMPILER LOCATION: Compiler set through project option: D:\uti\TI\ARM\4.0.0.LTS
CONFIGURATION: https://docs.platformio.org/page/boards/timspm0/lp-mspm0g3507.html
PLATFORM: Texas Instruments MSPM0 (0.0.0) > TI Launchpad MSPM0G3507
HARDWARE: 80MHz, 31.25KB RAM, 125KB Flash
DEBUG: Current (openocd_mspm0) On-board (openocd_mspm0) External (jlink)
PACKAGES:
[...]
Generating memory usage report...
*** [sizedata] AssertionError :
Traceback (most recent call last):
File "C:\Users\user\.platformio\packages\tool-scons\scons-local-4.8.1\SCons\Action.py", line 1441, in execute
result = self.execfunction(target=target, source=rsources, env=env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.platformio\packages\tool-scons\scons-local-4.8.1\SCons\Util\envs.py", line 252, in call
return self.method(*nargs, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.platformio\penv\Lib\site-packages\platformio\builder\tools\piosize.py", line 227, in DumpSizeData
for symbol in _collect_symbols_info(env, elffile, elf_path, sections):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.platformio\penv\Lib\site-packages\platformio\builder\tools\piosize.py", line 138, in _collect_symbols_info
symbol_locations = _get_symbol_locations(env, elf_path, symbol_addrs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\.platformio\penv\Lib\site-packages\platformio\builder\tools\piosize.py", line 54, in _get_symbol_locations
assert len(addrs) == len(locations)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError
========================== [FAILED] Took 3.29 seconds =========================="
Expected Results
Successfully completed analysis with memory sizes and symbol display for using binaries with different compilers.
Additional info
Location of Issue:
The Assertion issue arises in the "piosize.py" Core file.
This happens in actually 2 functions, but "_get_symbol_locations()" is called first as seen above in error log:
1. _get_symbol_locations()
48: def _get_symbol_locations(env, elf_path, addrs):
49: if not addrs:
50: return {}
51: cmd = [env.subst("$CC").replace("-gcc", "-addr2line"), "-e", elf_path]
52: result = _run_tool(cmd, env, addrs)
53: locations = [line for line in result["out"].split("\n") if line]
54: assert len(addrs) == len(locations)
55:
56: return dict(zip(addrs, [loc.strip() for loc in locations]))
2. _get_demangled_names()
59: def _get_demangled_names(env, mangled_names):
60: if not mangled_names:
61: return {}
62: result = _run_tool(
63: [env.subst("$CC").replace("-gcc", "-c++filt")], env, mangled_names
64: )
65: demangled_names = [line for line in result["out"].split("\n") if line]
66: assert len(mangled_names) == len(demangled_names)
67:
68: return dict(
69: zip(
70: mangled_names,
71: [dn.strip().replace("::FUNCTION", "") for dn in demangled_names],
72: )
73: )
Before doing the assert check the issue already occurs in Line 51-52 and 62-63 in "piosize.py".
Here it is assumed that the compiler command options "-gcc", -"addr2line" and "-c++filt" are available to get the address and demangled name of a symbol.
When using non-native or non-GCC compilers those commands are not always available and throw an error when calling it via "run_tool".
Therefore the assertion len check is going to fail afterwards.
Suggested Fix:
Instead of using the GCC Compiler specific commands to extract the necessary information, they can also already be fetched from the compiled binaries that contain the debug data in the DWARF format.
Many other compilers than GCC support this format out-of-the-box.
The Project Inspector already utilizes the "pyelftools" library in its core which supports also the extraction of DWARF information.
By combining the DWARF and ELF information and map them it is possible to achive the same results and to be compiler independent.
I just wanted to get some consensus on this issue before attempting a pull request with a suggested fix in "piosize.py".
I think some other PIO users would be happy as well if more different compiler variants within the Project Inspector can be supported natively from the PIO Core. :)
I'll be happy to receive feedback from you how you see this issue.
The text was updated successfully, but these errors were encountered: