Skip to content

Commit

Permalink
clear self.Vars before parsing elf file
Browse files Browse the repository at this point in the history
  • Loading branch information
XIVN1987 committed Nov 28, 2024
1 parent bc68504 commit f828f26
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
File renamed without changes
File renamed without changes
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ To use DAPLink, you need additional pyusb for CMSIS-DAPv2 and another usb-backen
pip install PyQt5 PyQtChart pyusb hidapi six pyelftools
```

![](./截屏.gif)
![](./Image/截屏.gif)

data format for wave show:
+ 1 wave: 11, 22, 33,
Expand All @@ -21,6 +21,6 @@ data format for wave show:
## J-Scope HSS mode
When select elf file path in address combobox, RTTView read selected variable directly from memory at specified address, rather from RTT buffer.

![](./截屏.jpg)
![](./Image/截屏.jpg)

Double-click the table cell to bring up the variable adding dialog.
8 changes: 5 additions & 3 deletions RTTView.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,16 +459,18 @@ def on_cmbAddr_currentIndexChanged(self, text):
try:
from elftools.elf.elffile import ELFFile
elffile = ELFFile(open(text, 'rb'))
except Exception as e:
print(f'open elf file fail: {e}')
else:

self.Vars = {}
for sym in elffile.get_section_by_name('.symtab').iter_symbols():
if sym.entry['st_info']['type'] == 'STT_OBJECT' and sym.entry['st_size'] in (1, 2, 4, 8):
self.Vars[sym.name] = Variable(sym.name, sym.entry['st_value'], sym.entry['st_size'])

for var in self.Vars.values():
print(f'{var.name:30s} @ {var.addr:08X}, len={var.size}')

except Exception as e:
print(f'parse elf file fail: {e}')

@pyqtSlot(int, int)
def on_tblVar_cellDoubleClicked(self, row, column):
if self.btnOpen.text() == '关闭连接': return
Expand Down

0 comments on commit f828f26

Please sign in to comment.