Patchwork Put a breakpoint on __asan_report_error for ASAN

login
register
mail settings
Submitter H.J. Lu
Date Nov. 29, 2012, 5:42 p.m.
Message ID <20121129174220.GB31369@intel.com>
Download mbox | patch
Permalink /patch/202798/
State New
Headers show

Comments

H.J. Lu - Nov. 29, 2012, 5:42 p.m.
Hi,

This patch puts a breakpoint on __asan_report_error if CFLAGS contains
-fsanitize=address, similar to fancy_abort and internal_error.  OK to
install?


H.J.
--
2012-11-24  H.J. Lu  <hongjiu.lu@intel.com>

	* configure.ac: Append gdbasan.in to .gdbinit if CFLAGS contains
	-fsanitize=address.
	* configure: Regenerated.

	* gdbasan.in: New file.
H.J. Lu - Nov. 29, 2013, 5:26 p.m.
On Thu, Nov 29, 2012 at 9:42 AM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> Hi,
>
> This patch puts a breakpoint on __asan_report_error if CFLAGS contains
> -fsanitize=address, similar to fancy_abort and internal_error.  OK to
> install?
>
>
> H.J.
> --
> 2012-11-24  H.J. Lu  <hongjiu.lu@intel.com>
>
>         * configure.ac: Append gdbasan.in to .gdbinit if CFLAGS contains
>         -fsanitize=address.
>         * configure: Regenerated.
>
>         * gdbasan.in: New file.
>
> diff --git a/gcc/configure b/gcc/configure
> index e2c119e..004910f 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -27032,6 +27032,14 @@ if test "x$subdirs" != x; then
>  fi
>  echo "source ${srcdir}/gdbinit.in" >> .gdbinit
>
> +# Put a breakpoint on __asan_report_error to help with debugging buffer
> +# overflow.
> +case "$CFLAGS" in
> +*-fsanitize=address*)
> +  echo "source ${srcdir}/gdbasan.in" >> .gdbinit
> +  ;;
> +esac
> +
>  gcc_tooldir='$(libsubdir)/$(libsubdir_to_prefix)$(target_noncanonical)'
>
>
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index c6f57bd..b9aaadb 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -5017,6 +5017,14 @@ if test "x$subdirs" != x; then
>  fi
>  echo "source ${srcdir}/gdbinit.in" >> .gdbinit
>
> +# Put a breakpoint on __asan_report_error to help with debugging buffer
> +# overflow.
> +case "$CFLAGS" in
> +*-fsanitize=address*)
> +  echo "source ${srcdir}/gdbasan.in" >> .gdbinit
> +  ;;
> +esac
> +
>  gcc_tooldir='$(libsubdir)/$(libsubdir_to_prefix)$(target_noncanonical)'
>  AC_SUBST(gcc_tooldir)
>  AC_SUBST(dollar)
> diff --git a/gcc/gdbasan.in b/gcc/gdbasan.in
> new file mode 100644
> index 0000000..cf05825
> --- /dev/null
> +++ b/gcc/gdbasan.in
> @@ -0,0 +1,3 @@
> +# Put a breakpoint on __asan_report_error to help with debugging buffer
> +# overflow.
> +b __asan_report_error
> --
> 1.7.11.7

Ping.
Dodji Seketeli - Dec. 2, 2013, 8:09 a.m.
"H.J. Lu" <hjl.tools@gmail.com> a écrit:

>> 2012-11-24  H.J. Lu  <hongjiu.lu@intel.com>
>>
>>         * configure.ac: Append gdbasan.in to .gdbinit if CFLAGS contains
>>         -fsanitize=address.
>>         * configure: Regenerated.
>>
>>         * gdbasan.in: New file.

This is OK, if nobody objects in the next 48h.

Thanks.

Patch

diff --git a/gcc/configure b/gcc/configure
index e2c119e..004910f 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -27032,6 +27032,14 @@  if test "x$subdirs" != x; then
 fi
 echo "source ${srcdir}/gdbinit.in" >> .gdbinit
 
+# Put a breakpoint on __asan_report_error to help with debugging buffer
+# overflow.
+case "$CFLAGS" in
+*-fsanitize=address*)
+  echo "source ${srcdir}/gdbasan.in" >> .gdbinit
+  ;;
+esac
+
 gcc_tooldir='$(libsubdir)/$(libsubdir_to_prefix)$(target_noncanonical)'
 
 
diff --git a/gcc/configure.ac b/gcc/configure.ac
index c6f57bd..b9aaadb 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5017,6 +5017,14 @@  if test "x$subdirs" != x; then
 fi
 echo "source ${srcdir}/gdbinit.in" >> .gdbinit
 
+# Put a breakpoint on __asan_report_error to help with debugging buffer
+# overflow.
+case "$CFLAGS" in
+*-fsanitize=address*)
+  echo "source ${srcdir}/gdbasan.in" >> .gdbinit
+  ;;
+esac
+
 gcc_tooldir='$(libsubdir)/$(libsubdir_to_prefix)$(target_noncanonical)'
 AC_SUBST(gcc_tooldir)
 AC_SUBST(dollar)
diff --git a/gcc/gdbasan.in b/gcc/gdbasan.in
new file mode 100644
index 0000000..cf05825
--- /dev/null
+++ b/gcc/gdbasan.in
@@ -0,0 +1,3 @@ 
+# Put a breakpoint on __asan_report_error to help with debugging buffer
+# overflow.
+b __asan_report_error