title: How can I break on UBSan reports in gdb and continue?
body: <p>Recent versions of GCC and Clang feature Undefined Behavior Sanitizer (UBSan) which is a compile flag (<code>-fsanitize=undefined</code>) that adds runtime instrumentation code. On errors, a warning such as this one is shown:</p>
  
  <blockquote>
    <p>packet-ber.c:1917:23: runtime error: left shift of 54645397829836991 by 8 places cannot be represented in type 'long int'</p>
  </blockquote>
  
  <p>Now I would like to debug this and get a debug break on said line. For Address Sanitizer (ASAN) there is <code>ASAN_OPTIONS=abort_on_error=1</code> which results in a fatal error that is catchable. The only UBSan option that seems usable is <a href="https://www.chromium.org/developers/testing/undefinedbehaviorsanitizer"><code>UBSAN_OPTIONS=print_stacktrace=1</code></a> which results in a call trace dump for reports. This however does not allow me to inspect the local variables and then continue the program. Use of <code>-fsanitize-undefined-trap-on-error</code> therefore not possible.</p>
  
  <p>How should I break in gdb on UBSan reports? While <code>break __sanitizer::SharedPrintfCode</code> seems to work, the name looks quite internal.</p>