While there are command line versions of strace for windows, the defacto GUI equivalent of strace on windows is Sysinternals procmon. In addition to letting you view file, registry, network and other system calls, procmon lets you send a simple string to it to allow for printf() debugging.

Is there an equivilant API call I can make on on unix that will send an arbitrary message to its strace output?


Thinking outside the box, you could call write() with a file descriptor that doesn't do anything with writes. For example,

int main()
    int d = open("/dev/null", 0);
    write(d, "hello world", 11);

Part of the resulting strace output on my system is:

open("/dev/null", O_RDONLY)             = 3
write(3, "hello world", 11)             = -1 EBADF (Bad file descriptor)

This is sufficient for short messages (longer ones may be truncated by strace).

  • That is a useful workaround. I think other than modifying strace itself, this is probably the answer. – Justin Dearing Dec 4 '14 at 20:35
  • 1
    Use -s to specify the maximum string length. – Stéphane Chazelas Dec 4 '14 at 20:55
  • Or any syscall that takes a string as argument (access("/MSG:" "hello world", F_OK), chdir("/MSG:" "hello world")...) – Stéphane Chazelas Dec 4 '14 at 20:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.