How can I get line numbering when running address sanitizer on gcc?
I have a simple program to test address santizer (buffer overflow):
#include<stdio.h>
int main(void)
{
int A[10] = {0};
A[10] = 1;
}
when running address sanitizer (gcc):
gcc b_oflow.c -fsanitize=address -g
==7961==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff90e56898 at pc 0x564401bc42be bp 0x7fff90e56840 sp 0x7fff90e56838
WRITE of size 4 at 0x7fff90e56898 thread T0
#0 0x564401bc42bd in main (/home/victor/Documents/code/C/lisp/src/a.out+0x12bd)
#1 0x7fbeb1a7009a in __libc_start_main ../csu/libc-start.c:308
#2 0x564401bc40b9 in _start (/home/victor/Documents/code/C/lisp/src/a.out+0x10b9)
Address 0x7fff90e56898 is located in stack of thread T0 at offset 72 in frame
#0 0x564401bc4184 in main (/home/victor/Documents/code/C/lisp/src/a.out+0x1184)
How can I get to output the line numbering? I've tried answers from questions: How do I get line numbers in the debug output with clang's -fsanitize=address? and How do I get line numbers in the debug output with clang's -fsanitize=address? but don't know what to do, I wanted to print the line where the overflow occurred when running the executable.