어떻게 내가 그래픽으로 표시 메모리 레이아웃에서.map file?[마감]
문제
내 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 을 출력:
다른 팁
I've written a C#프로그램 정보를 표시에도 파일과 함께 정보를 일반적으로 존재하지 않습에서도 파일에(같은 정적 상징을 사용할 수 있습 제공 binutils
).이 코드를 사용할 수 있습니다 기.에서 짧은 분석 map 파일 사용하기도 BINUTILS
(사용할 수 있는 경우)더 많은 정보를 수집.를 실행 그것은 당신이 필요하는 코드를 다운로드 및 실행 프로젝트를 visual studio 찾은 map 파일 경로를 클릭 Analyze
.
참고:만 작품에 대한 GCC/LD
맵파일
스크린샷:[
제휴하지 않습니다 StackOverflow