[PATCH] configure: add ABIGAIL_DEBUG options
Mark Wielaard
mark@klomp.org
Mon May 11 17:04:34 GMT 2020
Hi Matthias,
On Mon, 2020-05-11 at 17:24 +0200, Matthias Maennich via Libabigail wrote:
> When exporting ABIGAIL_DEBUG=1, the binaries compiled are especially
> suitable for debugging. The CFLAGS and CXXFLAGS that are added disable
> optimization and increase debug information levels.
>
> * configure.ac: add ABIGAIL_DEBUG environment variable for
> improved debugging capabilities
>
> Signed-off-by: Matthias Maennich <maennich@google.com>
> ---
> configure.ac | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/configure.ac b/configure.ac
> index 9f30ea38cf86..9aea79f49e9a 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -621,6 +621,11 @@ if test x$ABIGAIL_DEVEL != x; then
> CXXFLAGS="-g -Wall -Wextra -Werror"
> fi
>
> +if test x$ABIGAIL_DEBUG != x; then
> + CFLAGS="$CFLAGS -O0 -g3 -ggdb"
> + CXXFLAGS="$CXXFLAGS -O0 -g3 -ggdb"
> +fi
> +
I think you either want -O0 plus -fno-inline to make debugging even
easier. Or (better IMHO) use -Og so you do get some optimization, just
none that makes debugging harder. The advantage of -Og is that you can
then also add -D_FORTIFY_SOURCE=2 to detect various memory and string
operation bugger overflows early (or even at compile time).
You also will want to add -D_GLIBCXX_DEBUG which catches various
illegal uses of std iterators and algorithms. In fact I just tried it
and while running make check it found:
safe_iterator.h:360:error: attempt to advance
signed char dereferenceable (start-of-sequence) iterator -1
steps, which falls
outside its valid range.
Objects involved in the operation:
iterator @ 0x0x7fffffffc740 {
type =
__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<abigail::ir
::function_decl* const*,
std::__cxx1998::vector<abigail::ir::function_decl*,
std::allocator<abigail::ir::function_decl*> > >,
std::__debug::vector<abigail::ir::function_decl*,
std::allocator<abigail::ir::function_decl*> > > (constant iterator);
state = dereferenceable (start-of-sequence);
references sequence with type
`std::__debug::vector<abigail::ir::function_decl*,
std::allocator<abigail::ir::function_decl*> >' @ 0x0x7fffffffc740 }
Poking around in gdb found that in compute_diff () the a_base
RandomAccessOutputIterator could go back (-1) and then forward (+1)
again because there were missing brackets. That is undefined behavior
if we are at the beginning of the iterator.
Proposed fix attached.
Cheers,
Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Don-t-iterate-before-the-start-of-a-RandomAccessOutp.patch
Type: text/x-patch
Size: 1843 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libabigail/attachments/20200511/6124de7e/attachment.bin>
More information about the Libabigail
mailing list