Difference between revisions of "Third Eye"

From Infinity Wiki
Jump to navigation Jump to search
Line 6: Line 6:
=== I8C ===
=== I8C ===
* <code>NT_GNU_INFINITY</code> redefined as 8995 (<code>NT_GNU_PROPERTY_TYPE_0</code> is now 5)
* <code>NT_GNU_INFINITY</code> redefined as 8995 (<code>NT_GNU_PROPERTY_TYPE_0</code> is now 5).
* I8C now has an optimizer to save a single byte on s390x (woooohoooooooo!!!)
* I8C now optimizes out some constant math operations, specifically "add", "mul", "neg" and "sub".
=== glibc ===
=== glibc ===

Revision as of 08:51, 7 June 2017

Third Eye will be the third full-system preview release of Infinity. Third Eye will prototype new proc_service calls to allow clients to operate on non-live and containerized processes. Third Eye is planned to be released June 2017.

Changes since Infinity Second Wind


  • NT_GNU_INFINITY redefined as 8995 (NT_GNU_PROPERTY_TYPE_0 is now 5).
  • I8C now optimizes out some constant math operations, specifically "add", "mul", "neg" and "sub".


  • x86_64 now accesses %fs_base directly using I8_TS_REGISTER rather than using I8_TS_CTA_VALUE to access it via ps_get_thread_area.
  • libpthread.so now has all notes required to fill in all the td_thr_get_info fields that glibc's libthread_db fills in.
  • rtld notes renamed with object name as provider, and leading double underscores removed (will be marked private in some future release, but this allows notes to be flipped pri->pub without maybe having to supply compatibility notes)
  • thread::get_tls_addr(ppi)ip has been removed
  • thread::get_tlsbase(pi)ip tests now work on TLS_DTV_AT_TP architectures (i.e. aarch64)


  • NT_GNU_INFINITY redefined as 8995 (NT_GNU_PROPERTY_TYPE_0 is now 5)
  • The shim libthread_db will use ps_foreach_infinity_note, if present, rather than walking r_debug.
  • The shim libthread_db will use ps_get_register, if present, rather than hackily using ps_lgetregs.
  • The shim libthread_db's td_thr_get_info now fills in all fields that glibc's libthread_db fills in.
  • The shim libthread_db's td_thr_tls_get_addr uses link_map::get_tls_modid(p)i instead of thread::get_tls_addr(ppi)ip.


  • New component!

Building Infinity Third Eye

There are three things you need to build to try Third Eye: a glibc with Infinity notes, the shim libthread_db that accesses them, and a patched version of GDB.

Create a test build of glibc with Infinity notes

To build glibc with Infinity notes you first need to install I8C. For Third Eye you need I8C 0.0.5, which you can install with PIP:

pip install --user i8c==0.0.5

or you can build from source:

git clone https://gitlab.com/gbenson/i8c.git
cd i8c
git branch i8c-0.0.5 i8c-0.0.5-release
git checkout i8c-0.0.5
python setup.py test  # optional
python setup.py install --user

The command i8c needs to be in your path before you continue. Either of the above sequences will install I8C in ~/.local/bin/i8c, so you may need to add ~/.local/bin to your path. Alternatively you can omit the --user and install I8C globally on your system. However you install it, you need to be able to enter this exact command:

i8c --version | head -n 1

and see this exact output:

I8C 0.0.5

Once you have I8C installed you can proceed to build glibc:

mkdir -p glibc/build
git clone https://gitlab.com/gbenson/glibc.git glibc/src
cd glibc/src
git branch third-eye infinity-third-eye
git checkout third-eye
cd ../build
../src/configure --prefix=/usr --with-infinity

--with-infinity is assumed if you have I8C installed, but specifiying it explicitly here forces configure to check the version for you.

You should be able to see Infinity notes in libpthread.so and ld.so if everything worked. Both

readelf -n nptl/libpthread.so
readelf -n elf/ld.so

should list several notes with owner "GNU" and unknown type 0x2323:

Displaying notes found at file offset 0x0002144c with length 0x00000378:
  Owner                 Data size	Description
  GNU                  0x0000006d	Unknown note type: (0x00002323)
  GNU                  0x0000007d	Unknown note type: (0x00002323)
  GNU                  0x000000cc	Unknown note type: (0x00002323)
  GNU                  0x0000009f	Unknown note type: (0x00002323)
  GNU                  0x0000005f	Unknown note type: (0x00002323)
  GNU                  0x0000005b	Unknown note type: (0x00002323)

See https://sourceware.org/glibc/wiki/Testing/Builds for more information about glibc test builds.

Build libi8x with the shim libthread_db

To build libi8x with the shim libthread_db you first need to install the elfutils libelf development files. For Fedora and RHEL this is the elfutils-libelf-devel RPM. For Debian and Ubuntu the package you need is libelf-dev. Either way, once done you should see /usr/include/libelf.h on your system.

Once that's there, clone and build libi8x:

 git clone https://gitlab.com/gbenson/libi8x.git
 cd libi8x
 git branch libi8x-0.0.4 libi8x-0.0.4-release
 git checkout libi8x-0.0.4
 make check  # optional

You should see an examples/libthread_db.so.1 symbolic link if it worked.

Build patched GDB

For full functionality the shim libthread_db needs some patches to GDB:

mkdir -p gdb/build
git clone https://gitlab.com/gbenson/binutils-gdb.git gdb/src
cd gdb/src
git branch third-eye infinity-third-eye
git checkout third-eye
cd ../build
../src/configure --with-separate-debug-dir=/usr/lib/debug

The --with-separate-debug-dir option is the only option required for Fedora and RHEL. Other platforms may require other options. See https://sourceware.org/gdb/current/onlinedocs/gdb/Installing-GDB.html for more information about building GDB.

Once built, you should be able to run the patched GDB like this:

 gdb/gdb --data-directory=gdb/data-directory

Things to do with Infinity Third Eye

All Infinity First Flight and Second Wind examples are still relevant, with the proviso that you need modify the GDB invocations to use the modified GDB you just built.