Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6894671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:48:43+00:00 2026-05-27T06:48:43+00:00

I think that the wrapper framework in valgrind is pretty nice. I am trying

  • 0

I think that the wrapper framework in valgrind is pretty nice. I am trying to track differences between different code paths (as to why one works and another does not). Instead of trying to look at a difference of an strace output (which will not give me all details I need because I want to trace lib and sys calls I decided to use wrappers around a handful of functions.

The one function that got me scratching my head is fcntl.

The fcntl manpage declares it as follows

int fcntl(int fd, int cmd);
int fcntl(int fd, int cmd, long arg);
int fcntl(int fd, int cmd, struct flock *lock);

However as this is C and overloading does not come naturally to C, it is prototyped as follows in fcntl.h

extern int fcntl (int __fd, int __cmd, ...);

The end-user wrapping facility in valgrind supports N number of WORD arguments, but carries a warning about using the wrong number of args and I did not see a mention of any varargs.

A more classical varargs function like printf is typically implemented with a lower fixed args function vprintf which takes va_list as a single parameter. In such a case I would have wrapped vprintf rather than printf, but alas AFAIK fcntl does not have such an intermediate function.

My question is – what would a “safe” wrapper for fcntl look like?

For example, the following seems to work, but is it safe:

int I_WRAP_SONAME_FNNAME_ZU(libcZdsoZa,fcntl)(int fd, int cmd, ...)
{
  int result;
  OrigFn fn;
  void* arg;

  va_list argp;
  va_start(argp, cmd);
  arg=va_arg(argp, void*);

  VALGRIND_GET_ORIG_FN(fn);
  printf("@@fcntl wrapper: args fd=%d, cmd=%d, arg=%p ... ", fd, cmd, arg);
  CALL_FN_W_WWW(result, fn, fd, cmd, arg);
  printf("##fcntl wrapper: result %d\n", result);
  return result;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:48:44+00:00Added an answer on May 27, 2026 at 6:48 am

    Look syswrappers for sys_ioctl in valgrind sources in file coregrind/m_syswrap/syswrap-linux.c.

    Look at http://valgrind.org/docs/manual/dist.readme-missing.html for details.

    Maybe you will need to rebuild valgrind with your changes for syswrappers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen it mentioned sometimes that Repository Pattern is built into Entity Framework Code
I think that java executables (jar files) are trivial to decompile and get the
I think that business logic should exist in a model when using an MVC
I think that it used to the be the case that in Liferay 4,
just think that when I opened my file then when I want to write
I think that this problem can be sorted using reflection (a technology which I'm
I think that Visual Studio's biggest let down is the Javascript editor. I have
I think that the zipper is a beautiful idea; it elegantly provides a way
Do you think that writing about software (i.e. having a blog) and speaking on
I would like to think that some of the software I'm writing today will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.