This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Implement pahole-like 'ptype /o' option
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Date: Tue, 21 Nov 2017 11:16:47 -0500
- Subject: Re: [PATCH] Implement pahole-like 'ptype /o' option
- Authentication-results: sourceware.org; auth=none
- References: <20171121160709.23248-1-sergiodj@redhat.com>
On Tuesday, November 21 2017, I wrote:
[...]
> diff --git a/gdb/testsuite/gdb.base/ptype-offsets.cc b/gdb/testsuite/gdb.base/ptype-offsets.cc
> new file mode 100644
> index 0000000000..f6f845db74
> --- /dev/null
> +++ b/gdb/testsuite/gdb.base/ptype-offsets.cc
> @@ -0,0 +1,77 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> + Copyright 2017 Free Software Foundation, Inc.
> +
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see <http://www.gnu.org/licenses/>. */
> +
> +/* This file will be used to test 'ptype /o' on x86_64 only. */
> +
> +#include <stdint.h>
> +
> +/* A struct with many types of fields, in order to test 'ptype
> + /o'. */
> +
> +struct abc
> +{
> + /* Virtual destructor. */
> + virtual ~abc ()
> + {}
> +
> + /* 8-byte address. Because of the virtual destructor above, this
> + field's offset will be 8. */
> + void *field1;
> +
> + /* No hole here. */
> +
> + /* 4-byte int bitfield of 1-bit. */
> + unsigned int field2 : 1;
> +
> + /* 31-bit hole here. */
> +
> + /* 4-byte int. */
> + int field3;
> +
> + /* No hole here. */
> +
> + /* 1-byte char. */
> + char field4;
> +
> + /* 3-byte hole here. */
This should be "7-byte hole". I've updated my local tree.
--
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/