You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The generated LLVM code needs the ability to create Python stacktraces. So that when bounds check error, or string->int conversion error happens, we print a runtime stacktrace. So we need to get the stack addresses, convert them to LLVM functions, then use LLVM debugging information to find ASR functions that they correspond to, and finally ASR location information (that we need to store in the binary) to find the original Python file and line/column number where the error comes from. Then we can print Python style stacktraces at runtime.
We should use the ASR node itself to pass information about the name of the array or list that is out of bounds and also store the line/column number with the error message. #1093 (comment)
$ lpython examples/expr2.py -g --debug-with-line-column -o a.out
$ dsymutil a.outerror: cannot parse the debug map for 'a.out': The file was not recognized as a valid object file
Do we have any other alternative for this? Can we fix this error?
Are you trying to get these files for LPython? CMake already does it correctly, so you can just do what it does. Run dsymtil, llvm-dwarfdump, dwarf_convert.py, in the right directory, etc. However all of this is already done and it works.
What we need to do is something similar for binaries that we create.
Activity
certik commentedon Oct 20, 2022
One (orthogonal) issue to fix is:
certik commentedon Oct 20, 2022
To create runtime stacktraces, I would do the following to get started:
.dSYMwithlines.txtandlines.dat.lines.txtandlines.datin LPython/LFortran at compilation time:--debug-with-line-columnto convert linear location to line+column in the debug info #1256)-goption tolpython, if enabled, we will store debugging information (Initial debugging info implementation #1240)!dbg !23stuff for each emitted instruction (where it makes sense) (Initial debugging info implementation #1240)lines.txtandlines.datfiles.certik commentedon Oct 20, 2022
One can test this by:
Compile using:
and LLVM then stores debugging information for each instruction (and function), such as:
Thirumalai-Shaktivel commentedon Oct 27, 2022
Useful links:
https://llvm.org/docs/LangRef.html#metadata
https://stackoverflow.com/questions/19743861/what-is-llvm-metadata
Blog:
http://blog.llvm.org/2010/04/extensible-metadata-in-llvm-ir.html
https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.html#dwarf-emission-setup
Thirumalai-Shaktivel commentedon Nov 11, 2022
..
Thirumalai-Shaktivel commentedon Nov 24, 2022
I get the following error while using dsymutil:
Do we have any other alternative for this? Can we fix this error?
Thirumalai-Shaktivel commentedon Nov 24, 2022
I get the expected output using this:
Thirumalai-Shaktivel commentedon Nov 24, 2022
I think I was able to generate
lines.txtandlines.dat?How do I move forward with this issue?
@certik
Thirumalai-Shaktivel commentedon Nov 25, 2022
lpython/src/bin/CMakeLists.txt
Lines 27 to 38 in 67251c2
I used the same method as this. There seems to be a problem.
lpython.dSYM/lines.datis empty.Thirumalai-Shaktivel commentedon Nov 25, 2022
a.txt
./src/bin/lpython: file format elf64-x86-64.debug_line contents:
debug_line[0x00000000]
Line table prologue:
total_length: 0x00031e7a
format: DWARF32
version: 5
address_size: 8
seg_select_size: 0
prologue_length: 0x00000423
min_inst_length: 1
max_ops_per_inst: 1
default_is_stmt: 1
line_base: -5
line_range: 14
opcode_base: 13
standard_opcode_lengths[DW_LNS_copy] = 0
standard_opcode_lengths[DW_LNS_advance_pc] = 1
standard_opcode_lengths[DW_LNS_advance_line] = 1
standard_opcode_lengths[DW_LNS_set_file] = 1
standard_opcode_lengths[DW_LNS_set_column] = 1
standard_opcode_lengths[DW_LNS_negate_stmt] = 0
standard_opcode_lengths[DW_LNS_set_basic_block] = 0
standard_opcode_lengths[DW_LNS_const_add_pc] = 0
standard_opcode_lengths[DW_LNS_fixed_advance_pc] = 1
standard_opcode_lengths[DW_LNS_set_prologue_end] = 0
standard_opcode_lengths[DW_LNS_set_epilogue_begin] = 0
standard_opcode_lengths[DW_LNS_set_isa] = 1
include_directories[ 0] = "/home/thirumalai/Open_Source/lpython/src/bin"
include_directories[ 1] = "/home/thirumalai/Open_Source/lpython/src/bin"
include_directories[ 2] = "/usr/include/c++/11"
include_directories[ 3] = "/usr/include/c++/11/bits"
include_directories[ 4] = "/usr/include/x86_64-linux-gnu/c++/11/bits"
include_directories[ 5] = "/usr/include/c++/11/ext"
include_directories[ 6] = "/home/thirumalai/Open_Source/lpython/src/libasr"
include_directories[ 7] = "/home/thirumalai/Open_Source/lpython/src/libasr/pass"
include_directories[ 8] = "/home/thirumalai/Open_Source/lpython/src/bin/tpl/cpp-terminal"
include_directories[ 9] = "/usr/include/c++/11/debug"
include_directories[ 10] = "/usr/include/x86_64-linux-gnu/bits"
include_directories[ 11] = "/usr/include"
include_directories[ 12] = "/usr/lib/gcc/x86_64-linux-gnu/11/include"
include_directories[ 13] = "/usr/include/x86_64-linux-gnu/bits/types"
include_directories[ 14] = "/usr/include/x86_64-linux-gnu/sys"
include_directories[ 15] = "/usr/include/c++/11/pstl"
include_directories[ 16] = "/home/thirumalai/Open_Source/lpython/src/lpython"
include_directories[ 17] = "/home/thirumalai/Open_Source/lpython/src/lpython/semantics"
include_directories[ 18] = "/home/thirumalai/Open_Source/lpython/src/libasr/codegen"
include_directories[ 19] = "/home/thirumalai/Open_Source/lpython/src/lpython/parser"
file_names[ 0]:
name: "lpython.cpp"
dir_index: 1
file_names[ 1]:
name: "limits"
dir_index: 2
file_names[ 2]:
name: "chrono"
dir_index: 2
file_names[ 3]:
name: "exception.h"
dir_index: 3
file_names[ 4]:
name: "new"
dir_index: 2
file_names[ 5]:
name: "stl_algobase.h"
dir_index: 3
file_names[ 6]:
name: "char_traits.h"
dir_index: 3
file_names[ 7]:
name: "basic_string.h"
dir_index: 3
file_names[ 8]:
name: "charconv.h"
dir_index: 3
...
file_names[188]:
name: "unistd.h"
dir_index: 11
file_names[189]:
name: "system_error"
dir_index: 2
Address Line Column File ISA Discriminator Flags
0x0000000000809ef7 1065 7 1 0 0 is_stmt
0x0000000000809eff 1065 59 1 0 0 is_stmt
0x0000000000809f04 1065 62 1 0 0 is_stmt
0x0000000000809f06 1065 62 1 0 0 is_stmt end_sequence
0x0000000000809f06 1068 7 1 0 0 is_stmt
0x0000000000809f0e 1068 44 1 0 0 is_stmt
0x0000000000809f13 1068 57 1 0 0 is_stmt
0x0000000000809f15 1068 57 1 0 0 is_stmt end_sequence
0x0000000000809f15 1748 7 1 0 0 is_stmt
0x0000000000809f1d 1748 44 1 0 0 is_stmt
0x0000000000809f2a 1748 57 1 0 0 is_stmt
0x0000000000809f31 1748 57 1 0 0 is_stmt end_sequence
0x0000000000809f31 1751 7 1 0 0 is_stmt
0x0000000000809f39 1751 44 1 0 0 is_stmt
0x0000000000809f46 1751 57 1 0 0 is_stmt
0x0000000000809f4d 1751 57 1 0 0 is_stmt end_sequence
0x0000000000809f4e 537 2 2 0 0 is_stmt
0x0000000000809f5a 538 11 2 0 0 is_stmt
0x0000000000809f61 538 16 2 0 0 is_stmt
0x0000000000809f63 538 16 2 0 0 is_stmt end_sequence
0x0000000000809f64 521 23 2 0 0 is_stmt
0x0000000000809f74 522 10 2 0 0 is_stmt
0x0000000000809f7b 522 6 2 0 0 is_stmt
0x0000000000809f82 522 37 2 0 0 is_stmt
0x0000000000809f85 522 37 2 0 0 is_stmt end_sequence
0x0000000000809f85 432 2 2 0 0 is_stmt
0x0000000000809f8d 433 17 2 0 0 is_stmt
0x0000000000809f92 433 20 2 0 0 is_stmt
0x0000000000809f94 433 20 2 0 0 is_stmt end_sequence
0x0000000000809f94 521 23 2 0 0 is_stmt
0x0000000000809fa4 522 10 2 0 0 is_stmt
0x0000000000809fab 522 6 2 0 0 is_stmt
0x0000000000809fb2 522 37 2 0 0 is_stmt
0x0000000000809fb5 522 37 2 0 0 is_stmt end_sequence
0x0000000000809fb6 64 5 3 0 0 is_stmt
0x0000000000809fc2 64 34 3 0 0 is_stmt
0x0000000000809fd0 64 36 3 0 0 is_stmt
0x0000000000809fd3 64 36 3 0 0 is_stmt end_sequence
0x0000000000809fd3 175 1 4 0 0 is_stmt
0x0000000000809fe3 175 10 4 0 0 is_stmt
0x0000000000809fe7 175 15 4 0 0 is_stmt
0x0000000000809fe9 175 15 4 0 0 is_stmt end_sequence
0x0000000000809fe9 180 67 4 0 0 is_stmt
0x0000000000809ff9 180 69 4 0 0 is_stmt
0x0000000000809ffc 180 69 4 0 0 is_stmt end_sequence
0x0000000000809ffc 1010 40 5 0 0 is_stmt
0x000000000080a008 1010 49 5 0 0 is_stmt
0x000000000080a00c 1010 54 5 0 0 is_stmt
0x000000000080a00e 1010 54 5 0 0 is_stmt end_sequence
0x000000000080a00e 364 7 6 0 0 is_stmt
0x000000000080a01e 367 37 6 0 0 is_stmt
0x000000000080a025 367 10 6 0 0 is_stmt
0x000000000080a027 368 32 6 0 0 is_stmt
0x000000000080a02e 368 37 6 0 0 is_stmt
0x000000000080a033 369 7 6 0 0 is_stmt
0x000000000080a035 369 7 6 0 0 is_stmt end_sequence
0x000000000080a035 372 7 6 0 0 is_stmt
0x000000000080a04d 374 2 6 0 0 is_stmt
0x000000000080a054 375 11 6 0 0 is_stmt
0x000000000080a05e 379 6 6 0 1 is_stmt
0x000000000080a063 377 2 6 0 1 is_stmt
0x000000000080a067 381 18 6 0 0 is_stmt
0x000000000080a06f 381 6 6 0 0 is_stmt
0x000000000080a071 382 34 6 0 0 is_stmt
0x000000000080a07c 382 23 6 0 0 is_stmt
0x000000000080a087 382 14 6 0 0 is_stmt
0x000000000080a092 382 8 6 0 0 is_stmt
0x000000000080a096 383 11 6 0 0 is_stmt
0x000000000080a09d 384 39 6 0 0 is_stmt
0x000000000080a0a8 384 28 6 0 0 is_stmt
0x000000000080a0b3 384 19 6 0 0 is_stmt
0x000000000080a0be 384 13 6 0 0 is_stmt
0x000000000080a0c2 385 10 6 0 0 is_stmt
0x000000000080a0c9 381 6 6 0 2 is_stmt
0x000000000080a0ce 381 31 6 0 1 is_stmt
0x000000000080a0d8 386 13 6 0 0 is_stmt
0x000000000080a0df 389 25 6 0 0 is_stmt
0x000000000080a0f6 389 41 6 0 0 is_stmt
0x000000000080a0f7 390 7 6 0 0 is_stmt
0x000000000080a0f9 390 7 6 0 0 is_stmt end_sequence
...
certik commentedon Nov 25, 2022
Are you trying to get these files for LPython? CMake already does it correctly, so you can just do what it does. Run
dsymtil,llvm-dwarfdump,dwarf_convert.py, in the right directory, etc. However all of this is already done and it works.What we need to do is something similar for binaries that we create.
Thirumalai-Shaktivel commentedon Nov 26, 2022
I got it, Thank you.
I think I got confused or understood the above comments wrong.
Now, I know what to do.
Thirumalai-Shaktivel commentedon Sep 28, 2023
Related PR:
#1240
#1344
#1426