Third Eye

From Infinity Wiki
Jump to: navigation, search

Third Eye is the third full-system preview release of Infinity. Third Eye showcases new proc_service calls to allow GDB to operate on non-live processes and on processes running in sysroots. Third Eye was released June 7, 2017.

Changes since Infinity Second Wind

I8C

  • NT_GNU_INFINITY has been redefined as 8995 to avoid conflicting with NT_GNU_PROPERTY_TYPE_0.
  • I8C now optimizes out some constant math operations, specifically "add", "mul", "neg" and "sub".

glibc

  • 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.
  • All runtime linker notes have been renamed with object name as provider, and their leading double underscores removed.
  • The function thread::get_tls_addr(ppi)ip has been removed.
  • The tests for thread::get_tlsbase(pi)ip now work on aarch64.

libi8x

  • NT_GNU_INFINITY has been redefined as 8995 as for I8C.
  • 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 has been rewritten without using thread::get_tls_addr(ppi)ip.

GDB

  • DWARF register numbers for %fs_base and %gs_base have been added on x86_64.
  • Two new proc_service calls ps_get_register and ps_foreach_infinity_note have been added.

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
make

--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
 ./autogen.sh
 ./configure
 make
 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
make

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.