반응형
.map 파일에서 메모리 레이아웃을 그래픽으로 표시하려면 어떻게해야합니까?
내 gcc 빌드 도구 모음은 .map 파일을 생성합니다. 메모리 맵을 그래픽으로 어떻게 표시합니까?
다음은 Python 스크립트의 시작입니다. 섹션 및 기호 목록 (전반)에 맵 파일을로드합니다. 그런 다음 HTML을 사용하여지도를 렌더링합니다 (또는 sections
및 symbols
목록으로 원하는대로 수행 ).
다음 행을 수정하여 스크립트를 제어 할 수 있습니다.
with open('t.map') as f:
colors = ['9C9F84', 'A97D5D', 'F7DCB4', '5C755E']
total_height = 32.0
map2html.py
from __future__ import with_statement
import re
class Section:
def __init__(self, address, size, segment, section):
self.address = address
self.size = size
self.segment = segment
self.section = section
def __str__(self):
return self.section+""
class Symbol:
def __init__(self, address, size, file, name):
self.address = address
self.size = size
self.file = file
self.name = name
def __str__(self):
return self.name
#===============================
# Load the Sections and Symbols
#
sections = []
symbols = []
with open('t.map') as f:
in_sections = True
for line in f:
m = re.search('^([0-9A-Fx]+)\s+([0-9A-Fx]+)\s+((\[[ 0-9]+\])|\w+)\s+(.*?)\s*$', line)
if m:
if in_sections:
sections.append(Section(eval(m.group(1)), eval(m.group(2)), m.group(3), m.group(5)))
else:
symbols.append(Symbol(eval(m.group(1)), eval(m.group(2)), m.group(3), m.group(5)))
else:
if len(sections) > 0:
in_sections = False
#===============================
# Gererate the HTML File
#
colors = ['9C9F84', 'A97D5D', 'F7DCB4', '5C755E']
total_height = 32.0
segments = set()
for s in sections: segments.add(s.segment)
segment_colors = dict()
i = 0
for s in segments:
segment_colors[s] = colors[i % len(colors)]
i += 1
total_size = 0
for s in symbols:
total_size += s.size
sections.sort(lambda a,b: a.address - b.address)
symbols.sort(lambda a,b: a.address - b.address)
def section_from_address(addr):
for s in sections:
if addr >= s.address and addr < (s.address + s.size):
return s
return None
print "<html><head>"
print " <style>a { color: black; text-decoration: none; font-family:monospace }</style>"
print "<body>"
print "<table cellspacing='1px'>"
for sym in symbols:
section = section_from_address(sym.address)
height = (total_height/total_size) * sym.size
font_size = 1.0 if height > 1.0 else height
print "<tr style='background-color:#%s;height:%gem;line-height:%gem;font-size:%gem'><td style='overflow:hidden'>" % \
(segment_colors[section.segment], height, height, font_size)
print "<a href='#%s'>%s</a>" % (sym.name, sym.name)
print "</td></tr>"
print "</table>"
print "</body></html>"
다음은 출력되는 HTML의 잘못된 렌더링입니다.
일반적으로지도 파일에없는 정보 (예 : 사용할 수있는 정적 기호)와 함께지도 파일의 정보를 표시하는 C # 프로그램을 작성했습니다 binutils
. 코드는 여기에서 확인할 수 있습니다 . 간단히 말해 맵 파일을 구문 분석하고 BINUTILS
(사용 가능한 경우) 더 많은 정보를 수집하기 위해 사용합니다. 이를 실행하려면 코드를 다운로드하고 Visual Studio에서 프로젝트를 실행하고 맵 파일 경로를 찾은 다음을 클릭해야 Analyze
합니다.
참고 : GCC/LD
지도 파일 에서만 작동 합니다.
스크린 샷 : [
반응형
'UFO ET IT' 카테고리의 다른 글
C #을 사용하여 FTP 서버에 디렉터리를 어떻게 생성합니까? (0) | 2020.11.29 |
---|---|
Enumerable.Range와 기존 for 루프를 사용한 foreach에 대한 생각 (0) | 2020.11.29 |
IE8 / 9에서 jQuery 및 XDomainRequest가있는 CORS (0) | 2020.11.28 |
MVC 사용자 지정 유효성 검사 : 두 날짜 비교 (0) | 2020.11.28 |
코드에서 ActionBar 액션에 하위 메뉴 항목을 추가하는 방법은 무엇입니까? (0) | 2020.11.28 |