lua: Properly support high-range 64 addresses
authorVicent Marti <tanoku@gmail.com>
Fri, 15 Apr 2016 23:03:28 +0000 (01:03 +0200)
committerVicent Marti <tanoku@gmail.com>
Fri, 15 Apr 2016 23:18:39 +0000 (01:18 +0200)
commitfbf7193c5ddbace4550b758288d909a38e687955
treebeee3e9aafdd1599064ec8825d62c1e5e97e4eaf
parentb51da5e5ed387493f83e673ed5c2c7663ff485f6
lua: Properly support high-range 64 addresses

Lua's native Number type is a 64-bit double with 52-bit precision, which
was causing rounding errors when storing and working with high-range
memory addresses (namely, addresses from the kernel, which are all in
the `0xffffffff........` range).

To work around this, we've made sure to never call `tonumber` on any
variables that represent memory addresses, and instead continue
operating on them with their native types: LuaJIT can work with the
underlying `uint64_t` type for these values and transparently perform
all kinds of numeric operations.

The only limitation of working with native 64-bit types in LuaJIT is
that they cannot be printed with the language's default `string.format`
API. To give better UX to probe writers, these APIs have been
monkeypatched so the `%p` format specifier will now properly handle
64-bit addresses and print them in an appropriate format.
examples/lua/memleak.lua
examples/lua/offcputime.lua
src/lua/bcc/bpf.lua
src/lua/bcc/ld.lua
src/lua/bcc/sym.lua
src/lua/bcc/table.lua
src/lua/bcc/vendor/helpers.lua
src/lua/bcc/vendor/posix.lua