cross isa debugging in meta circular vms
play

Cross-ISA Debugging in Meta-circular VMs VMIL17 , 24 Oct 2017 - PowerPoint PPT Presentation

Cross-ISA Debugging in Meta-circular VMs VMIL17 , 24 Oct 2017 Christos Kotselidis Andy Nisbet Foivos S. Zakkak Nikos Foutris Except where otherwise noted, this presentation is licensed under the Creative Commons Attribution-ShareAlike 4.0


  1. Cross-ISA Debugging in Meta-circular VMs VMIL’17 , 24 Oct 2017 Christos Kotselidis Andy Nisbet Foivos S. Zakkak Nikos Foutris Except where otherwise noted, this presentation is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. Third party marks and brands are the property of their respective holders.

  2. 1 Introduction 1 / 19 Meta-circular VMs (create a boot image ) Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk ■ VMs written in the language they are meant to implement ■ Meta-circular VMs use their own compilers to build themselves

  3. 1 Introduction 2 / 19 Development challenges Porting Meta-circular VMs to new Instruction Set Architectures Debugging the boot image Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk ■ No existing compilers for the target ISA ■ Need to implement at least all the components required to build the boot image ■ Compiler bugs prevent the VM from starting ■ Testing of the compiler cannot be performed without the VM running ■ No suffjcient tools (e.g. testing framework) to assist in the above process ■ Exceptions might appear before we can even print and/or trace them

  4. 1 Introduction 2 / 19 Development challenges Porting Meta-circular VMs to new Instruction Set Architectures Debugging the boot image Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk ■ No existing compilers for the target ISA ■ Need to implement at least all the components required to build the boot image ■ Compiler bugs prevent the VM from starting ■ Testing of the compiler cannot be performed without the VM running ■ No suffjcient tools (e.g. testing framework) to assist in the above process ■ Exceptions might appear before we can even print and/or trace them

  5. 1 Introduction 3 / 19 Our approach Porting Meta-circular VMs to new Instruction Set Architectures Cross-compile unit tests and run using virtualization Debugging the boot image Injection of special assembly instructions acting as markers that helps us map the failing native function (even if inlined) to the corresponding VM method Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk

  6. 2 Background 4 / 19 Maxine VM maintained by the University of Manchester since project kenai shut down https://github.com/beehive-lab/Maxine-VM Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk ■ Meta-circular VM ■ Originally a Sun and Oracle Labs project, ■ Ported to ARMv7 using the tools presented in this talk ■ Ongoing porting to ARMv8 using the same tools

  7. 2 Background 5 / Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk Maxine VM Outline 19 Maxine VM Compilation Broker HeapScheme | GC SemiSpaceHeapScheme T1X: Baseline Compiler GenerationalHeapScheme C1X: Optimizing Compiler Graal: Optimizing Compiler Other Schemes JDK Integration ReferenceScheme LayoutScheme Threading MonitorScheme Native Calls | JNI Maxine C Code | Substrate

  8. 2 Background 6 / 19 Maxine’s Compilers + Fast compilation − Minimal to no optimizations C1X Optimizing compiler (C1 ported to Java) + Optimizing − Slower Compilation Graal Optimizing compiler (Alternative or complementary to C1X) + Aggressive Optimizations − Slower Compilation − Experimental Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk T1X Template based compiler, used instead of an interpreter

  9. 3 QEMU-based Cross-ISA Debugging Toolchain 7 / Cross-ISA Debugging in Meta-circular VMs $ arm-none-eabi-gdb # target remote localhost:1234 test_armv7.bin $ qemu-system-arm -cpu cortex-a9 -M versatilepb -m 128M -nographic -s -S -kernel $ arm-unknown-eabi-objcopy -O binary test.elf test_armv7.bin $ arm-unknown-eabi-ld -T test_armv7.ld test_armv7.o startup_armv7.o -o test.elf $ arm-unknown-eabi-as -mcpu=cortex-a9 -g startup_armv7.s -o startup_armv7.o $ arm-unknown-eabi-gcc -c -march=armv7-a -g test_armv7.c -o test_armv7.o QEMU-based Cross-ISA Debugging Toolchain 19 F. Zakkak - foivos.zakkak@manchester.ac.uk ■ Initialization (Create a code bufger, set expected values, etc.) ■ Code generation (fjll the bufger with the generated code) ■ Creation of an executable (assemble, compile, and link) ■ Run binary using QEMU and gdb ■ Validate results (compare register values to expected ones)

  10. 3 QEMU-based Cross-ISA Debugging Toolchain 8 / 19 Supported Kind of tests Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk ■ Individual Assembly Instructions ■ T1X Compiled Methods ■ C1X Compiled Methods

  11. 3 QEMU-based Cross-ISA Debugging Toolchain 9 / 19 Benefjts (e.g. x86 vs ARMv7) 1 $ time mx image 2 Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk ■ Ease porting to new ISAs by enabling cross-ISA debugging ■ Speedup regression and enhance productivity by: □ testing cross-ISA compilers on more powerful than the target machines □ not building the image for unit testing 132.67s user 3.60s system 421% cpu 32.365 total

  12. 4 Examples 10 / 19 Examples Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk Live demo at the end (if time permits)!

  13. 4 Examples 11 / Cross-ISA Debugging in Meta-circular VMs } 11 generateAndTest(expectedValues , testValues , bitmasks, asm.codeBuffer); 10 9 } 8 7 expectedValues[i] += expectedValues[i]; 6 5 asm.addq(ARMV7.cpuRegisters[i], expectedValues[i]); 4 asm.movImm32(ConditionFlag.Always, ARMV7.cpuRegisters[i], expectedValues[i]); 3 for ( int i = 0; i < 10; i++) { 2 public void test_add() throws Exception { 1 Unit Test for ARMv7 add Assembly Instruction 19 F. Zakkak - foivos.zakkak@manchester.ac.uk testValues[i] = true ;

  14. 4 Examples 6 Cross-ISA Debugging in Meta-circular VMs } 11 generateAndTest(expectedValues); 10 9 expected[0] = 3; 8 7 t1xCompiler.do_iadd(); t1xCompiler.do_iconst(2); 12 / 5 t1xCompiler.do_iconst(1); 4 3 initializeFrameForCompilation(); 2 public void test_add() throws Exception { 1 Unit Test for ARMv7 T1X add Template 19 F. Zakkak - foivos.zakkak@manchester.ac.uk

  15. 4 Examples */ Cross-ISA Debugging in Meta-circular VMs } 14 13 } 12 return a + b; 11 public static int test( byte a, byte b) { 10 9 public class BC_iadd2 { 8 7 13 / * @Runs: (-128b,1b)=-127; (127b,1b)=128; 6 * @Runs: (1b,2b)=3; (0b,-1b)=-1; (33b,67b)=100; (1b, -1b)=0; 5 * @Harness: java 4 /* 3 2 package jtt.bytecode; 1 BC_iadd2 Unit Test 19 F. Zakkak - foivos.zakkak@manchester.ac.uk

  16. 4 Examples Object[] registerValues = generateObjectsAndTestStubs(functionPrototype , int expectedValue = jtt.bytecode.BC_iadd2.test(argsOne[i], argsTwo[i]); 11 String functionPrototype = 12 ARMCodeWriter.preAmble("int", "int, int ", Integer.toString(argsOne[i]) + "," + Integer.toString(argsTwo[i])); 13 entryPoint , codeBytes); for ( int i = 0; i < argsOne.length; i++) { 14 assert (Integer) registerValues[0] == expectedValue; 15 } 16 } Cross-ISA Debugging in Meta-circular VMs 10 9 14 / byte [] argsTwo = {2, -1, 67, -1, 1, 1}; 19 Unit Test for ARMv7 C1X Compilation 1 public void test_C1X_jtt_BC_iadd2() throws Exception { 2 byte [] argsOne = {1, 0, 33, 1, -128, 127}; 3 4 8 initTests(); 5 String klassName = getKlassName("jtt.bytecode.BC_iadd"); 6 List<TargetMethod > methods = Compiler.compile( new String[] {klassName}, "C1X"); 7 F. Zakkak - foivos.zakkak@manchester.ac.uk initializeCodeBuffers(methods, "BC_iadd2.java", "int test(byte, byte)");

  17. 5 Limitations 15 / 19 Limitations We still can’t test the following without booting the VM As a result, starting the VM on the target ISA is expected to result in a number of hard faults (e.g. SIGSEGV ) Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk ■ Object allocation ■ Garbage collection ■ Synchronization ■ Inline assembly (compiler stubs, adapters from T1X to C1X, etc.)

  18. 6 Tracing Runtime Faults 16 / 19 Tracing Runtime Faults 1. that act as markers that we can easily fjnd when going through a gdb backtrace 2. holding a unique, per method, ID 1. Run the VM inside gdb 2. Print the backtrace 3. Look for the closest marker before the failing instruction 4. Obtain the method ID and look it up in the map fjle Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk ■ Extend C1X and T1X to inject special assembly instructions: ■ Create a fjle, mapping the unique IDs to the corresponding Java methods ■ On failure:

  19. 6 Tracing Runtime Faults 17 / Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk Tracing Runtime Faults Outline 19 Method Database Compiler (C1X | T1X) c1x | t1x_method_ids.txt Assembler append id offset method Parse method Add MethodIDNodes MethodIDLIRNode 1 0 foo( ) (parent) Task Graph Create foo( ) IR Graph in IR 1 12 bar( ) (inlined) generate MethodIDNode 2 0 … Inlined Call lower foo( ) assembly movw r8, 0xdead (r8:scratch) | marker MethodIDNode movt r8, 0xbeef | marker movw r8, id (bottom 16 bits) movt r8, id (upper 16 bits) … generated assembly of foo( )

  20. 7 Demo 18 / 19 Cross-ISA Debugging in Meta-circular VMs F. Zakkak - foivos.zakkak@manchester.ac.uk Demo Time

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend