[LLVMdev] arguments to standard library functions

Chris Lattner sabre at nondot.org
Sun Mar 20 21:19:06 PST 2005


On Mon, 21 Mar 2005, Abhijit Ray wrote:

> HI ,
> I understand that the standard C library functions are executed using the
> native  library  of the host machine. ( for example when we execute a bytecode
> to extract the profile info )
>
> Is it possible to extract for each standard library function that is
> executed , the arguments that the function is called with.
> For example if  printf ("%d", some_int )  when called during runtime
> with some_int = 243 i want to get that info .

Sure, you can do that multiple ways.  Perhaps the easiest would be to 
write an LLVM->LLVM pass which inspects all calls to external functions 
(e.g. printf) and inserts some code before or after it.  Thus it would 
turn:

   printf("%d", some_int);

into:

   log_printf_call(some_int);
   printf("%d", some_int);

Or something.  You can then provide an implementation of the logging 
runtime library to capture the data in any format you want.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list