Giter VIP home page Giter VIP logo

owee's Introduction

Owee is an experimental library to work with DWARF format.

OCaml users might find the Owee_location module interesting.

Provided an executable:

  • runs on Linux,
  • runs on a 64-bit x86 architecture,
  • contains debug symbols generated with DWARF 2 to DWARF 4,
  • contains native code,
  • is not relocated, and
  • does not use Dynlink.

Then it gives you the location of the definition of an arbitrary functional value. Linking the library is enough, no change to the toolchain is required.

There is partial support for DWARF 5; only symbol names and filenames are fully tested.

These restrictions can be relaxed. Open issues for platform you'd find interesting to support & on which you can test the library.

owee's People

Contributors

gretay-js avatar let-def avatar lpw25 avatar mshinwell avatar nandor avatar poechsel avatar reynir avatar rgrinberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

owee's Issues

nice library, what about a release?

Hey Fred,

what a great library. Would you mind to cut a release? the most recent one (0.3) in opam-repository does not include support for OCaml 4.12+.

Thanks,

Hannes

Feature: Working example for Owee_location

Thanks for doing this, it seems very handy!

I'm not able to get exposed functions in Owee_location to do... anything. I'm sure I'm doing something simple incorrectly.

Would it be possible to add a usage of Owee_location to examples?

This would both help as a starting point for usage and, if there is indeed something wrong, would help me begin debugging.

DWARF 5 is out

It saddens me, but GCC now defaults to DWARF v5. It would be nice to support it in Owee otherwise its going to be a PITA... Well, a brief overview of the DWARF 5 standard definition tells me it is going to be a PITA either way.

Symbol.name return truncated names

Can be clearly seen when applying functions on itself

% ./_build/default/functions.exe _build/default/functions.exe | head
All symbols:
0 (function)
65 (function)
dlib__55 (function)
r_tm_clones (function)

sh_1010 (function)
mat__58 (function)
rray__size_in_bytes_1328 (function)
ring__rindex_from_opt_1173 (function)

Looking at it with nm, it's pretty clear some names are truncated.

Could it be made that a dune utop works with this project?

Currently, a dune utop results in:

File "_build/default", line 1, characters 0-0:
ld: error: undefined symbol: caml_startup__code_begin
>>> referenced by owee_stubs.c:47
>>>               owee_stubs.o:(ml_owee_code_pointer) in archive src/libowee_stubs.a

ld: error: undefined symbol: caml_startup__code_end
>>> referenced by owee_stubs.c:47
>>>               owee_stubs.o:(ml_owee_code_pointer) in archive src/libowee_stubs.a
cc: error: linker command failed with exit code 1 (use -v to see invocation)
File "_none_", line 1:
Error: Error while building custom runtime system

Even for projects that depend on owee. It would be great to support bytecode targets, even if understandably owee woudn't work as expected. In the meantime we had to comment out the packages using owee to get an interactive session up and running.

Owee spends a lot of time sorting intervals

Hi!

While working on magic-trace, we found that we spend a long time (~20-30 seconds) loading some decently-sized binaries with Owee. These binaries have ~2 million symbols.

I captured a ~1ms trace of this:

p

It's all in building Owee_interval_trees.

I think we can build it substantially quicker while maintaining query speed, since we have the advantage of knowing up front all the symbols (such that we never have online interval additions), and we have functional maps. (Thanks @FatalEagle for much help with the algorithm here.) We would be building a sort of "prefix sum of maps".

Below is some simple pseudocode for replacing Owee_interval_tree, while allowing it to be built much faster:

type t = {
   maps : Map[left bound int, Map[right bound int, symbol]]
   ; cumulative_right_bound_to_interval_map : Map[right bound int, symbol]
}

fun build intervals:
    maps = {}
    cumulative_right_bound_to_interval_map = {}

    for ({ symbol = _, left, right } as interval) in intervals sorted by nondecreasing left bound:
        (* This step is "free" thanks to functional maps *)
        cumulative_right_bound_to_interval_map |= { right: interval }
        maps[left_bound] = cumulative_right_bound_to_interval_map

    return { maps; cumulative_right_bound_to_interval_map }

fun iter f:
    map(f, cumulative_right_bound_to_interval_map.values())

fun query addr:
    (* O(log n) time, n = size of [maps]
     * This is implementable with closest_key `Less_or_equal_to
     * https://ocaml.janestreet.com/ocaml-core/v0.12/doc/base/Base/Map/index.html#val-closest_key *)
    right_map = binary search maps for greatest left bound <= addr
	
    (* O(log n) time, n = size of [right_map]
     * This is implementable with [to_sequence ~lower_bound:<bound from above> ~upper_bound:addr]
     * https://ocaml.janestreet.com/ocaml-core/v0.12/doc/base/Base/Map/index.html#val-to_sequence *)
    return (right_map filtered for right bound >= addr).values()

The catch here is that while query is conceptually simple, closest_key and to_sequence are not provided in the standard library. Are we willing to take a dependency on Base here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.