I am working through the book Rust In Action (currently available through the Manning Early Access Program), and one of the author's debugging instructions is not working as expected. I don't know if there's actually anything wrong, maybe it's just a matter of peculiarities of different systems.
Anyway, there is an example program that is supposed to illustrate heap allocation, and the instructions say to compile the program with cargo build, then execute as follows:
But for me, the trace.txt file does not contain any information, except for:
--- SIGTERM (Terminated) ---
+++ killed by SIGTERM +++
I searched for relevant info and didn't find much, but I did see a forum post somewhere indicating that ltrace might not work on PIE executables, so I tried
Try putting the -*+malloc+free+realloc part between quotes.
That was the first thing I tried - because zsh complained about the glob expression. But quoting didn't make any difference. Also, since I just recently switched to zsh and there's a lot I don't understand about it, I also tried running the command in bash with and without quotes. Unfortunately, none of those measures make any difference.
IIRC ltrace only works with PLT calls, but I'm not sure how to convince rustc to link that way. I think you need -Zrelro-level=off/partial and -Zplt=on, but that doesn't seem to be sufficient.
Use readelf -r your-file to see what kind of relocations it has.
So I might need to use the nightly toolchain? I use rustup, so that wouldn't be a problem, but I generally stick to stable versions unless there's a specific need to do otherwise.
[I don't think the author of the book intends for it to be this complicated. I mean, it's probably all useful knowledge, but I'm not sure how deep I want to go into this rabbit hole right now I have submitted feedback saying that the instructions need more testing before the book is finalized]