[LLVMdev] [patch] New feature: debug info for function memory ranges (-jit-emit-debug-function-range)

Chris Lattner clattner at apple.com
Wed Jun 23 23:44:29 PDT 2010


On Jun 22, 2010, at 4:18 PM, Yuri wrote:

> On 06/19/2010 14:03, Yuri wrote:
>> This new option (--jit-emit-debug-function-range) will allow to output 
>> function information for memory ranges that functions occupy in memory 
>> while they run in JIT. File format generated is like this:
>> ...
>> 0x5000000 0x5001000 function_name_is_here
>> ...
>> 
>> This feature is useful for external tools like valgrind and 
>> google-perftools to profile the code when it is run in JIT. 
>> Particularly google-perftools will have a special option 
>> (--external_symbols) that will be able to import this file.
>> 
>> Note: to be useful this flag should be used with -disable-fp-elim to 
>> generate standard prologs.
>> 
>> Thank you,
>> Yuri
> 
> Anybody can check this in?

Hi Yuri,

This doesn't seem specific to the JIT.  Can you add this to the normal code generator, and have the JIT leverage off that?  Here are some minor comments, but the bigger issue of how this integrates seems important.


Instead of begin a flag in TargetOptions, can this be an ExecutionEngine parameter?


This doesn't look like a valid forward declaration:

+  raw_fd_ostream* JITEmitDebugInfoFunctionRangeStream(NULL);


+EmitJitDebugInfoFunctionRange("jit-emit-debug-function-range",
+  cl::desc("Emit debon memory address range information, one line per function"),

Typo in the cl::desc value.

+  // write brief debug info is requested
+  if (JITEmitDebugInfoFunctionRange) {
+    *JITEmitDebugInfoFunctionRangeStream << I.FnStart << " " << I.FnEnd << " " << F->getName() << "\n";
+  }
+

Stay in 80 cols (also elsewhere).

+    if (JITEmitDebugInfoFunctionRange && JITEmitDebugInfoFunctionRangeStream==NULL) {
+      std::string ErrorInfo;
+      static bool first_pass = true;
+      os = JITEmitDebugInfoFunctionRangeStream = new raw_fd_ostream("/tmp/llvm_debug_functions.txt", ErrorInfo, first_pass?0:raw_fd_ostream::F_Append);
+      if (!ErrorInfo.empty()) {

Please don't use statics.

-Chris



More information about the llvm-dev mailing list