bytehound icon indicating copy to clipboard operation
bytehound copied to clipboard

How to compile the 32-bit version of bytehound

Open Gary-Hobson opened this issue 2 years ago • 4 comments

I got an error when using bytehound: ERROR: ld.so: object './libbytehound.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored.

I guess it's because my app is 32bit version but bytehound is 64bit. So how should I compile bytehound for use by a 32-bit program?

System info: Linux dell-7060 5.15.0-46-generic #49~20.04.1-Ubuntu SMP Thu Aug 4 19:15:44 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Gary-Hobson avatar Aug 25 '22 06:08 Gary-Hobson

32-bit x86 is currently unsupported and won't work.

koute avatar Aug 25 '22 06:08 koute

When I try to compile by specifying the target target myself, I get some errors:(I put it at the bottom~)

When looking for the reason, I found that nwind only supports the amd64 platform...

(base) ➜  bytehound git:(master) ✗ cargo build --release -p bytehound-preload --target=i686-unknown-linux-gnu

   Compiling nwind v0.1.0 (https://github.com/koute/not-perf.git?rev=18bd8d3#18bd8d37)
   Compiling hashbrown v0.11.2
   Compiling perf_event_open v0.1.0 (https://github.com/koute/not-perf.git?rev=18bd8d3#18bd8d37)
error: failed to run custom build command for `nwind v0.1.0 (https://github.com/koute/not-perf.git?rev=18bd8d3#18bd8d37)`

Caused by:
  process didn't exit successfully: `/home/baerg/dev/repository/bytehound/target/release/build/nwind-d0c45efb2ceeb03e/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'unsupported target: i686-unknown-linux-gnu', /home/baerg/.cargo/git/checkouts/not-perf-af1a46759dd83df9/18bd8d3/nwind/build.rs:13:19
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

Gary-Hobson avatar Aug 25 '22 17:08 Gary-Hobson

For this problem, I think of another solution: I can hack all malloc (and other similar) in the program, and then output a memory-profiling_*.dat file, so that I can use bytehound server to show my analysis results .

But I'm sorry I'm not very familiar with rust, so I still don't know the format of the file after analyzing the code.

So, can you briefly describe the save format of the file, this is very important to me

Gary-Hobson avatar Aug 27 '22 09:08 Gary-Hobson

For this problem, I think of another solution: I can hack all malloc (and other similar) in the program, and then output a memory-profiling_*.dat file, so that I can use bytehound server to show my analysis results .

You're probably better off just using Heaptrack for this.

But I'm sorry I'm not very familiar with rust, so I still don't know the format of the file after analyzing the code.

So, can you briefly describe the save format of the file, this is very important to me

You should be able to figure it out from these:

https://github.com/koute/bytehound/blob/90fc09dc6b7bc7ab8bb5b97820bcd234bc1e80dd/common/src/event.rs#L115 https://github.com/koute/speedy#supported-types

The data file is composed of those Event enums serialized one after another using speedy.

koute avatar Aug 27 '22 11:08 koute