summaryrefslogtreecommitdiff
path: root/mysys/my_alloc.c
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-02-02 11:08:36 +0200
committerMonty <monty@mariadb.org>2018-02-02 11:08:36 +0200
commitd69642deddf4f8d51f8c6807361576451334f1f9 (patch)
tree4b20cf71f484a31fabbfbd85f2173cc1fea5be05 /mysys/my_alloc.c
parent1e5e3d562b867ae83c3fbb003465e1596c748690 (diff)
downloadmariadb-git-d69642deddf4f8d51f8c6807361576451334f1f9.tar.gz
Added name to MEM_ROOT for esier debugging
This will make it easier to how memory allocation is done when debugging with either DBUG or gdb. Will especially help when debugging stored procedures Main change is a name argument as second argument to init_alloc_root() init_sql_alloc() Other things: - Added DBUG_ENTER/EXIT to some Virtual_tmp_table functions
Diffstat (limited to 'mysys/my_alloc.c')
-rw-r--r--mysys/my_alloc.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c
index b2a1264bd2b..0dbd571c7fd 100644
--- a/mysys/my_alloc.c
+++ b/mysys/my_alloc.c
@@ -32,6 +32,7 @@
SYNOPSIS
init_alloc_root()
mem_root - memory root to initialize
+ name - name of memroot (for debugging)
block_size - size of chunks (blocks) used for memory allocation
(It is external size of chunk i.e. it should include
memory required for internal structures, thus it
@@ -51,13 +52,13 @@
Because of this, we store in MY_THREAD_SPECIFIC as bit 1 in block_size
*/
-void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
+void init_alloc_root(MEM_ROOT *mem_root, const char *name, size_t block_size,
size_t pre_alloc_size __attribute__((unused)),
myf my_flags)
{
DBUG_ENTER("init_alloc_root");
- DBUG_PRINT("enter",("root: %p prealloc: %zu", mem_root,
- pre_alloc_size));
+ DBUG_PRINT("enter",("root: %p name: %s prealloc: %zu", mem_root,
+ name, pre_alloc_size));
mem_root->free= mem_root->used= mem_root->pre_alloc= 0;
mem_root->min_malloc= 32;
@@ -69,6 +70,7 @@ void init_alloc_root(MEM_ROOT *mem_root, size_t block_size,
mem_root->block_num= 4; /* We shift this with >>2 */
mem_root->first_block_usage= 0;
mem_root->total_alloc= 0;
+ mem_root->name= name;
#if !(defined(HAVE_valgrind) && defined(EXTRA_DEBUG))
if (pre_alloc_size)
@@ -172,7 +174,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
#if defined(HAVE_valgrind) && defined(EXTRA_DEBUG)
reg1 USED_MEM *next;
DBUG_ENTER("alloc_root");
- DBUG_PRINT("enter",("root: %p", mem_root));
+ DBUG_PRINT("enter",("root: %p name: %s", mem_root, mem_root->name));
DBUG_ASSERT(alloc_root_inited(mem_root));
@@ -207,7 +209,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
reg1 USED_MEM *next= 0;
reg2 USED_MEM **prev;
DBUG_ENTER("alloc_root");
- DBUG_PRINT("enter",("root: %p", mem_root));
+ DBUG_PRINT("enter",("root: %p name: %s", mem_root, mem_root->name));
DBUG_ASSERT(alloc_root_inited(mem_root));
DBUG_EXECUTE_IF("simulate_out_of_memory",
@@ -298,6 +300,10 @@ void *multi_alloc_root(MEM_ROOT *root, ...)
char **ptr, *start, *res;
size_t tot_length, length;
DBUG_ENTER("multi_alloc_root");
+ /*
+ We don't need to do DBUG_PRINT here as it will be done when alloc_root
+ is called
+ */
va_start(args, root);
tot_length= 0;
@@ -382,7 +388,8 @@ void free_root(MEM_ROOT *root, myf MyFlags)
{
reg1 USED_MEM *next,*old;
DBUG_ENTER("free_root");
- DBUG_PRINT("enter",("root: %p flags: %u", root, (uint) MyFlags));
+ DBUG_PRINT("enter",("root: %p name: %s flags: %u", root, root->name,
+ (uint) MyFlags));
#if !(defined(HAVE_valgrind) && defined(EXTRA_DEBUG))
/*