vshcmd: > cat ~/test.cpp
cat ~/test.cpp
#include <string>
#include <iostream>

int determiner = 100;

__attribute__ ((noinline))
int may_raise_exception ()
{
  std::string mystring("Hello world");
  if (determiner >= mystring.length())
    throw "Some basic string.";
  return mystring[determiner];
}

int interface_function_cpp () {
  std::string otherstring("Hi there");
  return may_raise_exception ();
}

int main(int argc, char** argv)
{
  (void)argv;
  if (argc > 1)
   {
     determiner = argc;
     try {
       return interface_function_cpp ();
     }
     catch (char const *) {
       printf ("Caught the exception.\n");
     }
   }
  return 0;
}

ubuntu@ubuntu:~$ 
vshcmd: > gdb -q --args ~/test-exceptions $(seq 1 100)
gdb -q --args ~/test-exceptions $(seq 1 100)
Reading symbols from /home/ubuntu/test-exceptions...done.
(gdb) 
vshcmd: > start
start
Temporary breakpoint 1 at 0x66c60
Starting program: /home/ubuntu/test-exceptions 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/aarch64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 1, 0x0000aaaaaab10c60 in main (argc=-1087408024, 
    argv=0xfffffffff470)
(gdb) 
vshcmd: > break may_raise_exception
vshcmd: > break _Unwind_Resume
vshcmd: > break test.cpp:30
break may_raise_exception
Breakpoint 2 at 0xaaaaaab108f0: file /home/matmal01/test.cpp, line 9.
(gdb) break _Unwind_Resume
break test.cpp:30
Breakpoint 3 at 0xffffbf2f7b20: _Unwind_Resume. (4 locations)
(gdb) break test.cpp:30
Breakpoint 4 at 0xaaaaaab10dac: file /home/matmal01/test.cpp, line 30.
(gdb) 
vshcmd: > cont
cont
Continuing.

Breakpoint 2, may_raise_exception () at /home/matmal01/test.cpp:9
warning: Source file is more recent than executable.
9	  std::string mystring("Hello world");
(gdb) 
vshcmd: > print &mystring
vshcmd: > call __hwasan_print_shadow($sp, 0x200)
print &mystring
call __hwasan_print_shadow($sp, 0x200)
$1 = (std::__cxx11::string *) 0xfffffffff2f0
(gdb) call __hwasan_print_shadow($sp, 0x200)
HWASan shadow map for fffffffff240 .. fffffffff440 (pointer tag 0)
  fffffffff240: 0
  fffffffff250: 0
  fffffffff260: 0
  fffffffff270: 0
  fffffffff280: 0
  fffffffff290: 0
  fffffffff2a0: 0
  fffffffff2b0: 0
  fffffffff2c0: 0
  fffffffff2d0: 0
  fffffffff2e0: 6f
  fffffffff2f0: ef     // Here's `mystring` in `may_raise_exception`
  fffffffff300: ef
  fffffffff310: 0
  fffffffff320: 0
  fffffffff330: 0
  fffffffff340: 0
  fffffffff350: 0
  fffffffff360: 0
  fffffffff370: 0
  fffffffff380: 0
  fffffffff390: bf
  fffffffff3a0: 3f
  fffffffff3b0: 3f
  fffffffff3c0: 0
  fffffffff3d0: 0
  fffffffff3e0: 0
  fffffffff3f0: 0
  fffffffff400: 0
  fffffffff410: 0
  fffffffff420: 0
  fffffffff430: 0
(gdb) 
vshcmd: > bt
bt
#0  may_raise_exception () at /home/matmal01/test.cpp:9
#1  0x0000aaaaaab10b70 in interface_function_cpp ()
    at /home/matmal01/test.cpp:17
#2  0x0000aaaaaab10d0c in main (argc=101, argv=0xfffffffff5b8)
    at /home/matmal01/test.cpp:27
(gdb) 
vshcmd: > cont
cont
Continuing.

Breakpoint 3, 0x0000ffffbf42bd6c in _Unwind_Resume ()
   from /lib/aarch64-linux-gnu/libgcc_s.so.1
(gdb) 
vshcmd: > # Hit _Unwind_Resume, in may_raise_exception
vshcmd: > bt
bt
#0  0x0000ffffbf42bd6c in _Unwind_Resume ()
   from /lib/aarch64-linux-gnu/libgcc_s.so.1
#1  0x0000aaaaaab10ac4 in may_raise_exception () at /home/matmal01/test.cpp:13
#2  0x0000aaaaaab10b70 in interface_function_cpp ()
    at /home/matmal01/test.cpp:17
#3  0x0000aaaaaab10d0c in main (argc=101, argv=0xfffffffff5b8)
    at /home/matmal01/test.cpp:27
(gdb) 
vshcmd: > up
up
#1  0x0000aaaaaab10ac4 in may_raise_exception () at /home/matmal01/test.cpp:13
13	}
(gdb) 
vshcmd: > # Just to demonstrate there's no untagging done in this landing pad
vshcmd: > set pagination off
vshcmd: > disassemble
set pagination off
(gdb) disassemble
Dump of assembler code for function may_raise_exception():
        ....   snip   ....
   0x0000aaaaaab10a98 <+552>:	ret
   0x0000aaaaaab10a9c <+556>:	b	0xaaaaaab10aa0 <may_raise_exception()+560>
   0x0000aaaaaab10aa0 <+560>:	sub	x0, x29, #0x38
   0x0000aaaaaab10aa4 <+564>:	bl	0xaaaaaaad6688 <__hwasan_load8(__sanitizer::uptr)>
   0x0000aaaaaab10aa8 <+568>:	ldur	x0, [x29,#-56]
   0x0000aaaaaab10aac <+572>:	sub	x8, x29, #0x3c
   0x0000aaaaaab10ab0 <+576>:	str	x0, [sp]
   0x0000aaaaaab10ab4 <+580>:	mov	x0, x8
   0x0000aaaaaab10ab8 <+584>:	bl	0xaaaaaaad6630 <__hwasan_load4(__sanitizer::uptr)>
   0x0000aaaaaab10abc <+588>:	ldr	x0, [sp]
   0x0000aaaaaab10ac0 <+592>:	bl	0xaaaaaab11440 <_Unwind_Resume@plt>
      // As shown by the address in the backtrace this is the _Unwind_Resume
      // that we're calling from.
End of assembler dump.
(gdb) 
vshcmd: > # Have exited the landing pad, and it has not done the untagging.
vshcmd: > call __hwasan_print_shadow((void*)0xfffffffff240, 0x200)
call __hwasan_print_shadow((void*)0xfffffffff240, 0x200)
HWASan shadow map for fffffffff240 .. fffffffff440 (pointer tag 0)
  fffffffff240: 0
  fffffffff250: 0
  fffffffff260: 0
  fffffffff270: 0
  fffffffff280: 0
  fffffffff290: 0
  fffffffff2a0: 0
  fffffffff2b0: 0
  fffffffff2c0: 0
  fffffffff2d0: 0
  fffffffff2e0: 6f
  fffffffff2f0: ef
  fffffffff300: ef
  fffffffff310: 0
  fffffffff320: 0
  fffffffff330: 0
  fffffffff340: 0
  fffffffff350: 0
  fffffffff360: 0
  fffffffff370: 0
  fffffffff380: 0
  fffffffff390: bf
  fffffffff3a0: 3f
  fffffffff3b0: 3f
  fffffffff3c0: 0
  fffffffff3d0: 0
  fffffffff3e0: 0
  fffffffff3f0: 0
  fffffffff400: 0
  fffffffff410: 0
  fffffffff420: 0
  fffffffff430: 0
(gdb) 
vshcmd: > continue
continue
Continuing.

Breakpoint 3, 0x0000ffffbf42bd6c in _Unwind_Resume () from /lib/aarch64-linux-gnu/libgcc_s.so.1
(gdb) 
vshcmd: > # Now in interface_function_cpp
vshcmd: > bt
bt
#0  0x0000ffffbf42bd6c in _Unwind_Resume () from /lib/aarch64-linux-gnu/libgcc_s.so.1
#1  0x0000aaaaaab10c54 in interface_function_cpp () at /home/matmal01/test.cpp:18
#2  0x0000aaaaaab10d0c in main (argc=101, argv=0xfffffffff5b8) at /home/matmal01/test.cpp:27
(gdb) 
vshcmd: > # The previous function frame has been cleared by the personality
vshcmd: > # function wrapper.
vshcmd: > call __hwasan_print_shadow((void*)0xfffffffff240, 0x200)
call __hwasan_print_shadow((void*)0xfffffffff240, 0x200)
HWASan shadow map for fffffffff240 .. fffffffff440 (pointer tag 0)
  fffffffff240: 0
  fffffffff250: 0
  fffffffff260: 0
  fffffffff270: 0
  fffffffff280: 0
  fffffffff290: 0
  fffffffff2a0: 0
  fffffffff2b0: 0
  fffffffff2c0: 0
  fffffffff2d0: 0
  fffffffff2e0: 0
  fffffffff2f0: 0
  fffffffff300: 0
  fffffffff310: 0
  fffffffff320: 0
  fffffffff330: 0
  fffffffff340: 0
  fffffffff350: 0
  fffffffff360: 0
  fffffffff370: 0
  fffffffff380: 0
  fffffffff390: bf
  fffffffff3a0: 3f
  fffffffff3b0: 3f
  fffffffff3c0: 0
  fffffffff3d0: 0
  fffffffff3e0: 0
  fffffffff3f0: 0
  fffffffff400: 0
  fffffffff410: 0
  fffffffff420: 0
  fffffffff430: 0
(gdb) 
vshcmd: > break __hwasan_personality_wrapper
vshcmd: > cont
break __hwasan_personality_wrapper
Breakpoint 5 at 0xaaaaaaae07e8
(gdb) cont
Continuing.

Breakpoint 5, __hwasan_personality_wrapper (version=1, actions=2, exception_class=5138137972254386944, unwind_exception=0x7e00efe2ffffe060, context=0xffffffffef60, real_personality=0xffffbf5d0ad0 <__gxx_personality_v0>, get_gr=0xffffbf429c60 <_Unwind_GetGR>, get_cfa=0xffffbf429cb8 <_Unwind_GetCFA>) at /home/matmal01/llvm-project/compiler-rt/lib/hwasan/hwasan_exceptions.cpp:38
38	/home/matmal01/llvm-project/compiler-rt/lib/hwasan/hwasan_exceptions.cpp: No such file or directory.
(gdb) 
vshcmd: > # Still have the tags from the previous frame, but since this time
vshcmd: > # the frame is going to be left we'll clean it up.
vshcmd: > call __hwasan_print_shadow((void*)0xfffffffff240, 0x200)
call __hwasan_print_shadow((void*)0xfffffffff240, 0x200)
HWASan shadow map for fffffffff240 .. fffffffff440 (pointer tag 0)
  fffffffff240: 0
  fffffffff250: 0
  fffffffff260: 0
  fffffffff270: 0
  fffffffff280: 0
  fffffffff290: 0
  fffffffff2a0: 0
  fffffffff2b0: 0
  fffffffff2c0: 0
  fffffffff2d0: 0
  fffffffff2e0: 0
  fffffffff2f0: 0
  fffffffff300: 0
  fffffffff310: 0
  fffffffff320: 0
  fffffffff330: 0
  fffffffff340: 0
  fffffffff350: 0
  fffffffff360: 0
  fffffffff370: 0
  fffffffff380: 0
  fffffffff390: bf
  fffffffff3a0: 3f
  fffffffff3b0: 3f
  fffffffff3c0: 0
  fffffffff3d0: 0
  fffffffff3e0: 0
  fffffffff3f0: 0
  fffffffff400: 0
  fffffffff410: 0
  fffffffff420: 0
  fffffffff430: 0
(gdb) 
vshcmd: > disassemble
disassemble
Dump of assembler code for function __hwasan_personality_wrapper(int, _Unwind_Action, uint64_t, _Unwind_Exception*, _Unwind_Context*, PersonalityFn*, GetGRFn*, GetCFAFn*):
=> 0x0000aaaaaaae07e8 <+0>:	stp	x19, x20, [sp,#-48]!
   0x0000aaaaaaae07ec <+4>:	mov	w19, w1
   0x0000aaaaaaae07f0 <+8>:	mov	x20, x4
   0x0000aaaaaaae07f4 <+12>:	stp	x21, x22, [sp,#16]
   0x0000aaaaaaae07f8 <+16>:	mov	x21, x6
   0x0000aaaaaaae07fc <+20>:	str	x30, [sp,#32]
   0x0000aaaaaaae0800 <+24>:	mov	x22, x7
   0x0000aaaaaaae0804 <+28>:	cbz	x5, 0xaaaaaaae0830 <__hwasan_personality_wrapper(int, _Unwind_Action, uint64_t, _Unwind_Exception*, _Unwind_Context*, PersonalityFn*, GetGRFn*, GetCFAFn*)+72>
   0x0000aaaaaaae0808 <+32>:	blr	x5
   0x0000aaaaaaae080c <+36>:	and	w19, w19, #0x2
   0x0000aaaaaaae0810 <+40>:	cmp	w19, #0x0
   0x0000aaaaaaae0814 <+44>:	ccmp	w0, #0x8, #0x0, ne
   0x0000aaaaaaae0818 <+48>:	b.eq	0xaaaaaaae0848 <__hwasan_personality_wrapper(int, _Unwind_Action, uint64_t, _Unwind_Exception*, _Unwind_Context*, PersonalityFn*, GetGRFn*, GetCFAFn*)+96>
   0x0000aaaaaaae081c <+52>:	ldp	x21, x22, [sp,#16]
   0x0000aaaaaaae0820 <+56>:	ldr	x30, [sp,#32]
   0x0000aaaaaaae0824 <+60>:	ldp	x19, x20, [sp],#48
   0x0000aaaaaaae0828 <+64>:	ret
   0x0000aaaaaaae082c <+68>:	nop
   0x0000aaaaaaae0830 <+72>:	tbnz	w19, #1, 0xaaaaaaae0848 <__hwasan_personality_wrapper(int, _Unwind_Action, uint64_t, _Unwind_Exception*, _Unwind_Context*, PersonalityFn*, GetGRFn*, GetCFAFn*)+96>
   0x0000aaaaaaae0834 <+76>:	mov	w0, #0x8                   	// #8
   0x0000aaaaaaae0838 <+80>:	ldr	x30, [sp,#32]
   0x0000aaaaaaae083c <+84>:	ldp	x21, x22, [sp,#16]
   0x0000aaaaaaae0840 <+88>:	ldp	x19, x20, [sp],#48
   0x0000aaaaaaae0844 <+92>:	ret
   0x0000aaaaaaae0848 <+96>:	mov	x0, x20
   0x0000aaaaaaae084c <+100>:	mov	w1, #0x1d                  	// #29
   0x0000aaaaaaae0850 <+104>:	blr	x21
   0x0000aaaaaaae0854 <+108>:	mov	x19, x0
   0x0000aaaaaaae0858 <+112>:	mov	x0, x20
   0x0000aaaaaaae085c <+116>:	blr	x22
   0x0000aaaaaaae0860 <+120>:	sub	x1, x19, x0
   0x0000aaaaaaae0864 <+124>:	mov	w2, #0x0                   	// #0
   0x0000aaaaaaae0868 <+128>:	bl	0xaaaaaaae2ee8 <__hwasan::TagMemory(unsigned long, unsigned long, unsigned char)>
   0x0000aaaaaaae086c <+132>:	mov	w0, #0x8                   	// #8
   0x0000aaaaaaae0870 <+136>:	ldr	x30, [sp,#32]
   0x0000aaaaaaae0874 <+140>:	ldp	x21, x22, [sp,#16]
   0x0000aaaaaaae0878 <+144>:	ldp	x19, x20, [sp],#48
   0x0000aaaaaaae087c <+148>:	ret
End of assembler dump.
(gdb) 
vshcmd: > until *0x0000aaaaaaae086c
until *0x0000aaaaaaae086c
0x0000aaaaaaae086c in __hwasan_personality_wrapper (version=<optimized out>, actions=<optimized out>, exception_class=<optimized out>, unwind_exception=<optimized out>, context=0xffffffffef60, real_personality=<optimized out>, get_gr=0xffffbf429c60 <_Unwind_GetGR>, get_cfa=0xffffbf429cb8 <_Unwind_GetCFA>) at /home/matmal01/llvm-project/compiler-rt/lib/hwasan/hwasan_exceptions.cpp:60
60	in /home/matmal01/llvm-project/compiler-rt/lib/hwasan/hwasan_exceptions.cpp
(gdb) 
vshcmd: > call __hwasan_print_shadow((void*)0xfffffffff240, 0x200)
call __hwasan_print_shadow((void*)0xfffffffff240, 0x200)
HWASan shadow map for fffffffff240 .. fffffffff440 (pointer tag 0)
  fffffffff240: 0
  fffffffff250: 0
  fffffffff260: 0
  fffffffff270: 0
  fffffffff280: 0
  fffffffff290: 0
  fffffffff2a0: 0
  fffffffff2b0: 0
  fffffffff2c0: 0
  fffffffff2d0: 0
  fffffffff2e0: 0
  fffffffff2f0: 0
  fffffffff300: 0
  fffffffff310: 0
  fffffffff320: 0
  fffffffff330: 0
  fffffffff340: 0
  fffffffff350: 0
  fffffffff360: 0
  fffffffff370: 0
  fffffffff380: 0
  fffffffff390: 0
  fffffffff3a0: 0
  fffffffff3b0: 0
  fffffffff3c0: 0
  fffffffff3d0: 0
  fffffffff3e0: 0
  fffffffff3f0: 0
  fffffffff400: 0
  fffffffff410: 0
  fffffffff420: 0
  fffffffff430: 0
(gdb) 
