Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: haukepetersen/cosy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: chrysn-pull-requests/cosy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 8 commits
  • 2 files changed
  • 5 contributors

Commits on Jun 11, 2022

  1. cosy: allow to specify port

    benpicco committed Jun 11, 2022
    Copy the full SHA
    2e9ab56 View commit details

Commits on Jul 8, 2022

  1. Copy the full SHA
    679e72a View commit details

Commits on Dec 2, 2024

  1. Copy the full SHA
    72299ae View commit details
  2. Merge pull request #1 from RIOT-OS/fork-clarity

    README: Clarify that we do intend to keep developing here
    maribu authored Dec 2, 2024
    Copy the full SHA
    eb76924 View commit details
  3. Merge pull request #4 from benpicco/cosy_port

    cosy: allow to specify port
    maribu authored Dec 2, 2024
    Copy the full SHA
    2d07aca View commit details
  4. Merge pull request #3 from OlegHahm/pr/regex_fix

    adapt regex to fit current nm output
    maribu authored Dec 2, 2024
    Copy the full SHA
    b95e058 View commit details

Commits on Dec 6, 2024

  1. Transform regex string pattern into raw string

    This fix invalid escape sequence warnings.
    bastien-buil committed Dec 6, 2024
    Copy the full SHA
    c896499 View commit details
  2. Merge pull request #5 from TinyPART/FixWarningsFromEscapes

    Fix warnings from invalid escapes
    chrysn authored Dec 6, 2024
    Copy the full SHA
    a19b2a2 View commit details
Showing with 17 additions and 14 deletions.
  1. +3 −0 README.md
  2. +14 −14 cosy.py
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# cosy

Python tool analyzing memory usage and distribution in .elf files

The project was originally developed [by Hauke Petersen](https://github.com/haukepetersen/cosy);
the [RIOT project](https://riot-os.org/) is maintaining this fork to continue development.
28 changes: 14 additions & 14 deletions cosy.py
Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@
import frontend_server

ROOT = path.join(Path(path.abspath(__file__)).parent, "root")
PORT = 12345


def add_sym(target, sym):
@@ -162,7 +161,7 @@ def parse_elffile(elffile, prefix, appdir, riot_base=None):
c = re.compile(r"(?P<addr>[0-9a-f]+) "
r"(?P<type>[tbdTDB]) "
r"(?P<sym>[0-9a-zA-Z_$.]+)\s+"
r"(.+/)?"
r"(.*/)?"
r"("
r"{appdir}|"
r"{riot_base}|"
@@ -196,28 +195,28 @@ def parse_mapfile(mapfile):
with open(mapfile, 'r') as f:
for line in f:

if re.match("^\.text", line):
if re.match(r"^\.text", line):
cur_type = 't'
continue

if re.match("^\.(bss|stack)", line):
if re.match(r"^\.(bss|stack)", line):
cur_type = 'b'
continue

if re.match("^\.(relocate|data)", line):
if re.match(r"^\.(relocate|data)", line):
cur_type = 'd'
continue

# if re.match("^\..+", line):
if re.match("^OUTPUT.+", line):
# if re.match(r"^\..+", line):
if re.match(r"^OUTPUT.+", line):
add_sym(res, cur_sym)
cur_type = ''
# continue
break

if cur_type:
# fill bytes?
m = re.match("^ *\*fill\* +0x([0-9a-f]+) +0x([0-9a-f])+", line)
m = re.match(r"^ *\*fill\* +0x([0-9a-f]+) +0x([0-9a-f])+", line)
if m:
add_sym(res, cur_sym)
cur_sym = {
@@ -235,7 +234,7 @@ def parse_mapfile(mapfile):
continue

# start of a new symbol
m = re.match(" \.([a-z]+\.)?([-_\.A-Za-z0-9$.]+)", line)
m = re.match(r" \.([a-z]+\.)?([-_\.A-Za-z0-9$.]+)", line)
if m:
# save last symbol
add_sym(res, cur_sym)
@@ -254,22 +253,22 @@ def parse_mapfile(mapfile):
}

# get size, addr and path of current symbol
m = re.match(".+0x([0-9a-f]+) +0x([0-9a-f]+) (/.+)$", line)
m = re.match(r".+0x([0-9a-f]+) +0x([0-9a-f]+) (/.+)$", line)
if m:
cur_sym['addr'] = int(m.group(1), 16)
cur_sym['size'] = int(m.group(2), 16)
# get object and archive files
me = re.match(".+/([-_a-zA-Z0-9]+\.a)\(([-_a-zA-Z0-9]+\.o)\)$", m.group(3))
me = re.match(r".+/([-_a-zA-Z0-9]+\.a)\(([-_a-zA-Z0-9]+\.o)\)$", m.group(3))
if me:
cur_sym['arcv'] = me.group(1)
cur_sym['obj'] = me.group(2)
me = re.match(".+/([-_a-zA-Z0-9]+\.o)$", m.group(3))
me = re.match(r".+/([-_a-zA-Z0-9]+\.o)$", m.group(3))
if me:
cur_sym['arcv'] = ''
cur_sym['obj'] = me.group(1)
continue

m = re.match(" +0x[0-9a-f]+ +([-_a-zA-Z0-9]+)$", line)
m = re.match(r" +0x[0-9a-f]+ +([-_a-zA-Z0-9]+)$", line)
if m:
cur_sym['alias'].append(m.group(1))
return res
@@ -352,6 +351,7 @@ def check_completeness(symbols):
p.add_argument("-c", type=argparse.FileType('w'),
help="Write module sizes to cvs file")
p.add_argument("-d", action="store_true", help="Don't run as web server")
p.add_argument("--port", default="12345", help="Webserver port", type=int)
args = p.parse_args()

# extract path to elf and map file
@@ -407,4 +407,4 @@ def check_completeness(symbols):
print(subprocess.check_output((args.p + 'size', elffile)).decode("utf-8"))

if not args.d:
frontend_server.run(ROOT, PORT, 'index.html')
frontend_server.run(ROOT, args.port, 'index.html')