[Commits] Rev 4108: Debugging aid: Add T* List<T>::elem(int n) which returns N-th element in the list. in file:///home/psergey/dev2/5.5/

Sergey Petrunya psergey at askmonty.org
Tue Mar 11 20:07:04 EET 2014


At file:///home/psergey/dev2/5.5/

------------------------------------------------------------
revno: 4108
revision-id: psergey at askmonty.org-20140311180702-1pntx903p1df1fyn
parent: psergey at askmonty.org-20140311161448-o77v9alz8xow2aad
committer: Sergey Petrunya <psergey at askmonty.org>
branch nick: 5.5
timestamp: Tue 2014-03-11 19:07:02 +0100
message:
  Debugging aid: Add T* List<T>::elem(int n) which returns N-th element in the list.
  - There was List<N>::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. 
=== modified file 'sql/sql_list.h'
--- a/sql/sql_list.h	2013-02-28 21:47:29 +0000
+++ b/sql/sql_list.h	2014-03-11 18:07:02 +0000
@@ -330,11 +330,12 @@ class base_list :public Sql_alloc
   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 @@ class base_list :public Sql_alloc
     }
     return data;
   }
+#endif
+
 #ifdef LIST_EXTRA_DEBUG
   /*
     Check list invariants and print results into trace. Invariants are:
@@ -528,7 +531,9 @@ template <class T> class List :public ba
     }
     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
 };
 
 

=== modified file 'sql/sql_test.cc'
--- a/sql/sql_test.cc	2013-06-01 19:33:26 +0000
+++ b/sql/sql_test.cc	2014-03-11 18:07:02 +0000
@@ -409,6 +409,15 @@ void print_sjm(SJ_MATERIALIZATION_INFO *
 }
 /* purecov: end */
 
+/*
+  Debugging help: force List<...>::elem function not be removed as unused.
+*/
+Item* (List<Item>:: *dbug_list_item_elem_ptr)(int)= &List<Item>::elem;
+Item_equal* (List<Item_equal>:: *dbug_list_item_equal_elem_ptr)(int)=
+  &List<Item_equal>::elem;
+TABLE_LIST* (List<TABLE_LIST>:: *dbug_list_table_list_elem_ptr)(int) =
+  &List<TABLE_LIST>::elem;
+
 #endif
 
 typedef struct st_debug_lock



More information about the commits mailing list