Closed Quuxplusone closed 3 years ago
Attached system.wat.gz
(916071 bytes, application/gzip): The actual file, produced by the FPC compiler, that causes the crash. Gzipped to fit the 1MB bugzilla file attachment limit.
Hi, thanks for the bug report.
We haven't looked at this in detail yet, but if you're going to be trying out
DWARF I would definitely recommend working from the main branch, as we've put a
lot of work on debugging since the LLVM 11 branch, and are continuing to work
on it actively.
This turns the crash into an error: https://reviews.llvm.org/D95838
We're not sure what the assembly in question is meant to accomplish, though it
seems to want to put data in a text section, which is not supported in Wasm.
The offending bit of code in your output is:
.section .text.b_DEBUGSTART_$SYSTEM,"",@
.globl DEBUGSTART_$SYSTEM
.type DEBUGSTART_$SYSTEM,@object
DEBUGSTART_$SYSTEM:
# End asmlist al_begin
# Begin asmlist al_procedures
.section .text.n_system_$$_errno2inoutres$word$$word,"",@
Here, DEBUGSTART_$SYSTEM is defined as "object".
(In reply to Wouter van Oortmerssen from comment #2)
> This turns the crash into an error: https://reviews.llvm.org/D95838
>
> We're not sure what the assembly in question is meant to accomplish, though
> it seems to want to put data in a text section, which is not supported in
> Wasm.
> The offending bit of code in your output is:
>
> .section .text.b_DEBUGSTART_$SYSTEM,"",@
> .globl DEBUGSTART_$SYSTEM
> .type DEBUGSTART_$SYSTEM,@object
> DEBUGSTART_$SYSTEM:
> # End asmlist al_begin
> # Begin asmlist al_procedures
>
> .section .text.n_system_$$_errno2inoutres$word$$word,"",@
>
> Here, DEBUGSTART_$SYSTEM is defined as "object".
Thanks!
The DEBUGSTART_$SYSTEM and DEBUGEND_$SYSTEM symbols are used as labels in order
to define the DW_AT_low_pc and DW_AT_high_pc attributes for the
DW_TAG_compile_unit tag for the system unit. What is the correct way to specify
these attributes with Wasm? Should DEBUGSTART_$SYSTEM and DEBUGEND_$SYSTEM be
defined as zero length functions? Or should we use some totally different
approach for this target?
I don't think you actually need to define symbols for this purpose.
For example, I tried using clang's assembly output to compile a simple function
with debug info:
__attribute__((noinline)) int inc(int x) {
return x + 1;
}
int main() {
return inc(0);
}
The beginning of the assembly output for "inc"
.hidden inc # -- Begin function inc
.globl inc
.type inc,@function
inc: # @inc
.Lfunc_begin0: <-- this is just a label, but not a symbol
.file 1 "/s/emr/emscripten-releases" "fib.c"
.loc 1 1 0 # fib.c:1:0
.functype inc (i32) -> (i32)
.local i32, i32, i32, i32, i32, i32
# %bb.0: <- code in the first basic block below
And then further down in the beginning of the .debug_info section:
.section .debug_info,"",@
.Lcu_begin0:
.int32 .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit
.Ldebug_info_start0:
.int16 4 # DWARF version number
.int32 .debug_abbrev0 # Offset Into Abbrev. Section
.int8 4 # Address Size (in bytes)
.int8 1 # Abbrev [1] 0xb:0x62 DW_TAG_compile_unit
.int32 .Linfo_string0 # DW_AT_producer
.int16 12 # DW_AT_language
.int32 .Linfo_string1 # DW_AT_name
.int32 .Lline_table_start0 # DW_AT_stmt_list
.int32 .Linfo_string2 # DW_AT_comp_dir
.int32 0 # DW_AT_low_pc
.int32 .Ldebug_ranges0 # DW_AT_ranges
.int8 2 # Abbrev [2] 0x26:0x27 DW_TAG_subprogram
.int32 .Lfunc_begin0 # DW_AT_low_pc
.int32 .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
The last 2 lines refer to labels in the text section.
Ok, the new error landed: https://reviews.llvm.org/D95838
That should fix this particular bug, but let me know if you run into other
issues.
system.wat.gz
(916071 bytes, application/gzip)