Ignore:
Timestamp:
Oct 26, 2021, 8:52:37 AM (4 years ago)
Author:
[email protected]
Message:

[JSC] Improve offlineasm debug annotations for Linux/ELF
https://bugs.webkit.org/show_bug.cgi?id=232303

Patch by Xan López <Xan Lopez> on 2021-10-26
Reviewed by Mark Lam.

This patch does two things:

Add the .size and .type directives to every llint "function"
(global, llint opcode, 'glue'). This allows a debugger to tell you
in what logical function you are inside the giant chunk of code
that is the llint interpreter. So instead of something like this:

(gdb) x/5i $pc

=> 0xf5f8af60 <wasmLLIntPCRangeStart+3856>: b.n 0xf5f8af6c <wasmLLIntPCRangeStart+3868>

0xf5f8af62 <wasmLLIntPCRangeStart+3858>: ldr r2, [r7, #8]
0xf5f8af64 <wasmLLIntPCRangeStart+3860>: ldr r2, [r2, #28]
0xf5f8af66 <wasmLLIntPCRangeStart+3862>: subs r0, #16
0xf5f8af68 <wasmLLIntPCRangeStart+3864>: ldr.w r0, [r2, r0, lsl #3]

you get something like this:

(gdb) x/5i $pc

=> 0xf5f8c770 <wasm_f32_add+12>: bge.n 0xf5f8c77c <wasm_f32_add+24>

0xf5f8c772 <wasm_f32_add+14>: add.w r6, r7, r9, lsl #3
0xf5f8c776 <wasm_f32_add+18>: vldr d0, [r6]
0xf5f8c77a <wasm_f32_add+22>: b.n 0xf5f8c78c <wasm_f32_add+40>
0xf5f8c77c <wasm_f32_add+24>: ldr r2, [r7, #8]

The other change adds a local symbol (in addition to an internal
label) to all the "glue" labels. That allows wasm opcodes to be
seen by the debugger (and the user to break on them), among other
things.

  • CMakeLists.txt: tell offlineasm we use the ELF binary format on Linux.
  • llint/LowLevelInterpreter.cpp: emit a non-local label for "glue" labels.
  • offlineasm/asm.rb: emit the .size and .type directives for every

llint "function" on ELF systems.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/offlineasm/asm.rb

    r284341 r284868  
    265265            end
    266266        end
     267        if $emitELFDebugDirectives
     268            deferNextLabelAction {
     269                putStr("    \".size #{labelName} , . - #{labelName} \\n\"")
     270                putStr("    \".type #{labelName} , function \\n\"")
     271            }
     272        end
    267273        @newlineSpacerState = :none # After a global label, we can use another spacer.
    268274    end
     
    342348$options = {}
    343349OptionParser.new do |opts|
    344     opts.banner = "Usage: asm.rb asmFile offsetsFile outputFileName [--assembler=<ASM>] [--webkit-additions-path=<path>]"
     350    opts.banner = "Usage: asm.rb asmFile offsetsFile outputFileName [--assembler=<ASM>] [--webkit-additions-path=<path>] [--binary-format=<format>]"
    345351    # This option is currently only used to specify the masm assembler
    346352    opts.on("--assembler=[ASM]", "Specify an assembler to use.") do |assembler|
     
    349355    opts.on("--webkit-additions-path=PATH", "WebKitAdditions path.") do |path|
    350356        $options[:webkit_additions_path] = path
     357    end
     358    opts.on("--binary-format=FORMAT", "Specify the binary format used by the target system.") do |format|
     359        $options[:binary_format] = format
    351360    end
    352361end.parse!
     
    366375$emitWinAsm = isMSVC ? outputFlnm.index(".asm") != nil : false
    367376$commentPrefix = $emitWinAsm ? ";" : "//"
     377
     378# We want this in all ELF systems we support, except for C_LOOP (we'll disable it later on if we are building cloop)
     379$emitELFDebugDirectives = $options.has_key?(:binary_format) && $options[:binary_format] == "ELF"
    368380
    369381inputHash =
     
    413425                $enableDebugAnnotations = false
    414426                $preferredCommentStartColumn = 60
     427                $emitELFDebugDirectives = false
    415428            end
    416429
Note: See TracChangeset for help on using the changeset viewer.