npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

arm-objdump-parser

v1.0.0

Published

Parses output from arm-none-eabi-objdump

Downloads

6

Readme

ARM Objdump Parser

Parsing C++ code is a very hard problem because C++ has an undecidable grammar. This is a pain when you want to generate wrappers based on C++ classes, like we do for the JerryScript project. Instead of parsing the code we opted for a different approach: parsing the debug information the compiler generates. This guarantees that we have a 100% accurate understanding of the application and its functions.

Live demo

The ARM Objdump Parser (AOP) is a JavaScript module (for node.js and web) which takes the output of arm-none-eabi-objdump and creates a searchable tree. For example, here is the query and the output for the DigitalOut constructor in mbed OS 5:

Query:

// children length of 3 = this (because member function) + 2 arguments
dump.nodes.filter(f => f.name === 'DigitalOut' && f.tag === 'subprogram' && f.children.length === 3)

Output (filtered):

{
  name: 'DigitalOut',
  accessibility: '1\t(public)',
  type:
   { tag: 'pointer_type',
     type:
      { tag: 'class_type',
        name: 'DigitalOut' } },
  children:
   [ { tag: 'formal_parameter',
       type:
        { tag: 'typedef',
          name: 'PinName',
          type:
           { tag: 'enumeration_type',
             // drilling down this list will give you all the possible enumeration values
             children: [Object] } } },
     { tag: 'formal_parameter',
       type:
        { tag: 'base_type',
          byte_size: '4',
          name: 'int' } }
   ]
}

Creating an objdump

To create an objdump that can be read out by the parser, first create a debug build of your application. On mbed OS 5 you can do this via:

$ mbed compile --profile ./mbed-os/tools/profiles/debug.json

This gives you an .elf file with the debug symbols. You can extract the symbols from the elf file via:

$ arm-none-eabi-objdump -Wi -g *.elf > symbols.txt

The symbols file can be read by AOP.

Usage (node.js)

Add the module to your project, via:

$ npm install arm-objdump-parser --save

Then use it via:

const objdumpParser = require('./arm-objdump-parser');
const fs = require('fs');

var dump = objdumpParser(fs.readFileSync('./symbols.txt', 'utf-8'));
var digitalOut = dump.nodes.filter(f => f.name === 'DigitalOut' && f.tag === 'class_type')[0];

console.log(digitalOut);

Usage (web)

Download objdump-parser.js, and add it to your web page via:

<script src="objdump-parser.js"></script>

Then use it via:

var dump = window.objdumpParser(/* get the symbols file from somewhere */);
var digitalOut = dump.nodes.filter(f => f.name === 'DigitalOut' && f.tag === 'class_type')[0];

console.log(digitalOut);

Tips

  • Only functions that are linked into the application are available.
  • Templated functions are accessible by a name which includes their template types, e.g. Client<MQTTNetwork, Countdown, 100, 5>.
  • Enum values are accessible under the children property of their type.