llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.1k stars 11.6k forks source link

Need 'x86_icebp' debug intrinsic for x86 #5771

Open b374043b-35b5-422a-b8ed-de440d214f13 opened 14 years ago

b374043b-35b5-422a-b8ed-de440d214f13 commented 14 years ago
Bugzilla Link 5399
Version trunk
OS All
CC @lattner,@sunfishcode

Extended Description

It will be great to add intrinsic 'x86_icebp' with opcode 0xF1 ( not documented, but supported by all x86 hardware ) intrinsic for X86 to simplify JIT debugging with Visual Studio ( it breaks execution and immediately jumps to disassembly without prompting ).

lattner commented 14 years ago

No, that violates the specification of llvm.trap. Trap does not continue.

b374043b-35b5-422a-b8ed-de440d214f13 commented 14 years ago

icebp patch

b374043b-35b5-422a-b8ed-de440d214f13 commented 14 years ago

Alright, what about changing behaviour of existing 'llvm.trap' instruction? Without attached debugger on Win32 program will terminated as with 'ud2' instruction. With attached debugger we get more debug-friendly trap unlike current one. I guess patch for it should looks like attached file ( I retain 'ud2' name coz GNU 'as' don't recognize 'icebp' intruction unlike 'objdump' )

lattner commented 14 years ago

This is a target specific thing. I'm not opposed to adding target specific builtins to expose things (e.g. cpuid would be a nice one on x86) but I don't want to generalizing something that isn't general. Anyway, I don't know of anyone working on this. Unless you plan to do it, I'll move it to the X86 README.txt file which is where we keep random ideas for new features (non-bugs).

b374043b-35b5-422a-b8ed-de440d214f13 commented 14 years ago

Another idea is to add target-specific 'dbg.trap' instrinsic with opcode 0xf1 for x86 backend or change behaviour of 'llvm.trap' to generate 'icebp' instead of 'ud2'.

sunfishcode commented 14 years ago

Is this general enough to warrant an intrinsic? This might be better off done with inline asm.

b374043b-35b5-422a-b8ed-de440d214f13 commented 14 years ago

Visual Studio catches 'ud2' but disallow to continue execution and terminating app after step over. For 'int3' / 'int 3' VS shows dialog with break/continue buttons. With 'icebp' VS immediately breaks at location showing disassembly (nicest behaviour =) ).

lattner commented 14 years ago

Sure, this should be easy to add if you're interested. Does llvm.trap (which codegens to ud2) do what you need? If not, adding something similar should be easy.