From b0b699dc278faa7cfbc0f54766d02cee762663a9 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Tue, 11 Mar 2014 19:07:02 +0100 Subject: [PATCH] Debugging aid: Add T* List::elem(int n) which returns N-th element in the list. - There was List::nth_element() but it didn't work because linker removed it. - Now, removal by linker is prevented for important values of T, and function is renamed. --- sql/sql_list.h | 9 +++++++-- sql/sql_test.cc | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sql/sql_list.h b/sql/sql_list.h index aef2f8d5f25..7538f69766d 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -330,11 +330,12 @@ public: friend class error_list; friend class error_list_iterator; +#ifndef DBUG_OFF /* Debugging help: return N-th element in the list, or NULL if the list has less than N elements. */ - inline void *nth_element(int n) + void *elem(int n) { list_node *node= first; void *data= NULL; @@ -350,6 +351,8 @@ public: } return data; } +#endif + #ifdef LIST_EXTRA_DEBUG /* Check list invariants and print results into trace. Invariants are: @@ -528,7 +531,9 @@ public: } empty(); } - inline T *nth_element(int n) { return (T*)base_list::nth_element(n); } +#ifndef DBUG_OFF + T *elem(int n) { return (T*)base_list::elem(n); } +#endif }; diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 311400c0c6c..ec426e39ee3 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -409,6 +409,15 @@ void print_sjm(SJ_MATERIALIZATION_INFO *sjm) } /* purecov: end */ +/* + Debugging help: force List<...>::elem function not be removed as unused. +*/ +Item* (List:: *dbug_list_item_elem_ptr)(int)= &List::elem; +Item_equal* (List:: *dbug_list_item_equal_elem_ptr)(int)= + &List::elem; +TABLE_LIST* (List:: *dbug_list_table_list_elem_ptr)(int) = + &List::elem; + #endif typedef struct st_debug_lock