mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-21 04:42:53 +08:00
3876875113
ASAN reports an error, -var-create container @ c^M =================================================================^M ^[[1m^[[31m==21639==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x6030000805c0^M ^[[1m^[[0m #0 0x7f2449b01b2a in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99b2a)^M #1 0xbb601d in update_dynamic_varobj_children ../../binutils-gdb/gdb/varobj.c:794^M #2 0xbb6556 in varobj_get_num_children(varobj*) ../../binutils-gdb/gdb/varobj.c:854^M #3 0x580cb4 in print_varobj ../../binutils-gdb/gdb/mi/mi-cmd-var.c:61^M #4 0x58138b in mi_cmd_var_create(char*, char**, int) ../../binutils-gdb/gdb/mi/mi-cmd-var.c:145^M #5 0x5967ce in mi_cmd_execute ../../binutils-gdb/gdb/mi/mi-main.c:2301^M #6 0x594b05 in captured_mi_execute_command ../../binutils-gdb/gdb/mi/mi-main.c:2001 .... ^M ^[[1m^[[32m0x6030000805c0 is located 0 bytes inside of 32-byte region [0x6030000805c0,0x6030000805e0)^M ^[[1m^[[0m^[[1m^[[35mallocated by thread T0 here:^[[1m^[[0m^M #0 0x7f2449b00602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)^M #1 0x7d1596 in xmalloc ../../binutils-gdb/gdb/common/common-utils.c:43^M #2 0x604176 in py_varobj_iter_new ../../binutils-gdb/gdb/python/py-varobj.c:159^M #3 0x6042da in py_varobj_get_iterator(varobj*, _object*) ../../binutils-gdb/gdb/python/py-varobj.c:198^M #4 0xbb5806 in varobj_get_iterator ../../binutils-gdb/gdb/varobj.c:720^M #5 0xbb5b9b in update_dynamic_varobj_children ../../binutils-gdb/gdb/varobj.c:758^M gdb: 2017-02-23 Yao Qi <yao.qi@linaro.org> * varobj-iter.h (varobj_iter_delete): Call xfree instead of delete.
73 lines
2.0 KiB
C++
73 lines
2.0 KiB
C++
/* Iterator of varobj.
|
|
Copyright (C) 2013-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/>. */
|
|
|
|
/* A node or item of varobj, composed of the name and the value. */
|
|
|
|
typedef struct varobj_item
|
|
{
|
|
/* Name of this item. */
|
|
std::string name;
|
|
|
|
/* Value of this item. */
|
|
struct value *value;
|
|
} varobj_item;
|
|
|
|
struct varobj_iter_ops;
|
|
|
|
/* A dynamic varobj iterator "class". */
|
|
|
|
struct varobj_iter
|
|
{
|
|
/* The 'vtable'. */
|
|
const struct varobj_iter_ops *ops;
|
|
|
|
/* The varobj this iterator is listing children for. */
|
|
struct varobj *var;
|
|
|
|
/* The next raw index we will try to check is available. If it is
|
|
equal to number_of_children, then we've already iterated the
|
|
whole set. */
|
|
int next_raw_index;
|
|
};
|
|
|
|
/* The vtable of the varobj iterator class. */
|
|
|
|
struct varobj_iter_ops
|
|
{
|
|
/* Destructor. Releases everything from SELF (but not SELF
|
|
itself). */
|
|
void (*dtor) (struct varobj_iter *self);
|
|
|
|
/* Returns the next object or NULL if it has reached the end. */
|
|
varobj_item *(*next) (struct varobj_iter *self);
|
|
};
|
|
|
|
/* Returns the next varobj or NULL if it has reached the end. */
|
|
|
|
#define varobj_iter_next(ITER) (ITER)->ops->next (ITER)
|
|
|
|
/* Delete a varobj_iter object. */
|
|
|
|
#define varobj_iter_delete(ITER) \
|
|
do \
|
|
{ \
|
|
if ((ITER) != NULL) \
|
|
{ \
|
|
(ITER)->ops->dtor (ITER); \
|
|
xfree (ITER); \
|
|
} \
|
|
} while (0)
|