You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

462 lines
10 KiB

Added all changes from old 4.0 version: PSTACK, libmysqld and MySQL filesystem UPDATE ... ORDER BY DELETE ... ORDER BY New faster fulltext handling Faster compressed keys Makefile.am: Added support for pstack and libmysqld_dir acconfig.h: MySQL filesystem and PSTACK acinclude.m4: MySQL File system client/mysql.cc: Support for --xml configure.in: Pstack, MySQL FS and libmysqld_dir include/ft_global.h: Faster fulltext include/my_pthread.h: Made c++ safe include/myisam.h: Update for faster fulltext include/mysql_com.h: new my_net_read() include/violite.h: libmysqld libmysql/net.c: New protocol that supports big packets myisam/Makefile.am: Faster fulltext myisam/ft_parser.c: Faster fulltext myisam/ft_search.c: Faster fulltext myisam/ft_update.c: Faster fulltext myisam/ftdefs.h: Faster fulltext myisam/mi_check.c: Faster fulltext myisam/mi_open.c: Faster compressed keys myisam/mi_search.c: Faster compressed keys myisam/mi_update.c: Faster compressed keys myisam/myisamdef.h: Faster compressed keys myisam/sort.c: Faster compressed keys mysql-test/mysql-test-run.sh: --skip-innobase and --skip-bdb sql/ChangeLog: Changelog sql/Makefile.am: PSTACK sql/mysql_priv.h: New ORDER BY options and libmysqld sql/mysqld.cc: PSTACK sql/net_serv.cc: New protocol that supports big packets sql/share/estonian/errmsg.txt: New error messages sql/sql_base.cc: Better list_open_tabels sql/sql_delete.cc: ORDER BY for delete sql/sql_lex.cc: Added language convertation of all strings sql/sql_parse.cc: Changes for libmysqld Use new ORDER BY options sql/sql_show.cc: Character set convertations Use new list_open_tables function. sql/sql_update.cc: UPDATE ... ORDER BY sql/sql_yacc.yy: Clean up symbol definitions DELETE .. ORDER BY UPDATE .. ORDER BY sql/table.h: new OPEN_TABLE_LIST structure BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
25 years ago
  1. /* rddbg.c -- Read debugging information into a generic form.
  2. Copyright (C) 1995, 96, 1997 Free Software Foundation, Inc.
  3. Written by Ian Lance Taylor <ian@cygnus.com>.
  4. This file is part of GNU Binutils.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  16. 02111-1307, USA. */
  17. /* This file reads debugging information into a generic form. This
  18. file knows how to dig the debugging information out of an object
  19. file. */
  20. #include <bfd.h>
  21. #include "bucomm.h"
  22. #include <libiberty.h>
  23. #include "debug.h"
  24. #include "budbg.h"
  25. static boolean read_section_stabs_debugging_info
  26. PARAMS ((bfd *, asymbol **, long, PTR, boolean *));
  27. static boolean read_symbol_stabs_debugging_info
  28. PARAMS ((bfd *, asymbol **, long, PTR, boolean *));
  29. static boolean read_ieee_debugging_info PARAMS ((bfd *, PTR, boolean *));
  30. static void save_stab PARAMS ((int, int, bfd_vma, const char *));
  31. static void stab_context PARAMS ((void));
  32. static void free_saved_stabs PARAMS ((void));
  33. /* Read debugging information from a BFD. Returns a generic debugging
  34. pointer. */
  35. PTR
  36. read_debugging_info (abfd, syms, symcount)
  37. bfd *abfd;
  38. asymbol **syms;
  39. long symcount;
  40. {
  41. PTR dhandle;
  42. boolean found;
  43. dhandle = debug_init ();
  44. if (dhandle == NULL)
  45. return NULL;
  46. if (! read_section_stabs_debugging_info (abfd, syms, symcount, dhandle,
  47. &found))
  48. return NULL;
  49. if (bfd_get_flavour (abfd) == bfd_target_aout_flavour)
  50. {
  51. if (! read_symbol_stabs_debugging_info (abfd, syms, symcount, dhandle,
  52. &found))
  53. return NULL;
  54. }
  55. if (bfd_get_flavour (abfd) == bfd_target_ieee_flavour)
  56. {
  57. if (! read_ieee_debugging_info (abfd, dhandle, &found))
  58. return NULL;
  59. }
  60. /* Try reading the COFF symbols if we didn't find any stabs in COFF
  61. sections. */
  62. if (! found
  63. && bfd_get_flavour (abfd) == bfd_target_coff_flavour
  64. && symcount > 0)
  65. {
  66. #if 0
  67. /*
  68. * JZ: Do we need coff?
  69. */
  70. if (! parse_coff (abfd, syms, symcount, dhandle))
  71. #else
  72. fprintf (stderr, "%s: COFF support temporarily disabled\n",
  73. bfd_get_filename (abfd));
  74. return NULL;
  75. #endif
  76. return NULL;
  77. found = true;
  78. }
  79. if (! found)
  80. {
  81. fprintf (stderr, "%s: no recognized debugging information\n",
  82. bfd_get_filename (abfd));
  83. return NULL;
  84. }
  85. return dhandle;
  86. }
  87. /* Read stabs in sections debugging information from a BFD. */
  88. static boolean
  89. read_section_stabs_debugging_info (abfd, syms, symcount, dhandle, pfound)
  90. bfd *abfd;
  91. asymbol **syms;
  92. long symcount;
  93. PTR dhandle;
  94. boolean *pfound;
  95. {
  96. static struct
  97. {
  98. const char *secname;
  99. const char *strsecname;
  100. } names[] = { { ".stab", ".stabstr" } };
  101. unsigned int i;
  102. PTR shandle;
  103. *pfound = false;
  104. shandle = NULL;
  105. for (i = 0; i < sizeof names / sizeof names[0]; i++)
  106. {
  107. asection *sec, *strsec;
  108. sec = bfd_get_section_by_name (abfd, names[i].secname);
  109. strsec = bfd_get_section_by_name (abfd, names[i].strsecname);
  110. if (sec != NULL && strsec != NULL)
  111. {
  112. bfd_size_type stabsize, strsize;
  113. bfd_byte *stabs, *strings;
  114. bfd_byte *stab;
  115. bfd_size_type stroff, next_stroff;
  116. stabsize = bfd_section_size (abfd, sec);
  117. stabs = (bfd_byte *) xmalloc (stabsize);
  118. if (! bfd_get_section_contents (abfd, sec, stabs, 0, stabsize))
  119. {
  120. fprintf (stderr, "%s: %s: %s\n",
  121. bfd_get_filename (abfd), names[i].secname,
  122. bfd_errmsg (bfd_get_error ()));
  123. return false;
  124. }
  125. strsize = bfd_section_size (abfd, strsec);
  126. strings = (bfd_byte *) xmalloc (strsize);
  127. if (! bfd_get_section_contents (abfd, strsec, strings, 0, strsize))
  128. {
  129. fprintf (stderr, "%s: %s: %s\n",
  130. bfd_get_filename (abfd), names[i].strsecname,
  131. bfd_errmsg (bfd_get_error ()));
  132. return false;
  133. }
  134. if (shandle == NULL)
  135. {
  136. shandle = start_stab (dhandle, abfd, true, syms, symcount);
  137. if (shandle == NULL)
  138. return false;
  139. }
  140. *pfound = true;
  141. stroff = 0;
  142. next_stroff = 0;
  143. for (stab = stabs; stab < stabs + stabsize; stab += 12)
  144. {
  145. bfd_size_type strx;
  146. int type;
  147. int other;
  148. int desc;
  149. bfd_vma value;
  150. /* This code presumes 32 bit values. */
  151. strx = bfd_get_32 (abfd, stab);
  152. type = bfd_get_8 (abfd, stab + 4);
  153. other = bfd_get_8 (abfd, stab + 5);
  154. desc = bfd_get_16 (abfd, stab + 6);
  155. value = bfd_get_32 (abfd, stab + 8);
  156. if (type == 0)
  157. {
  158. /* Special type 0 stabs indicate the offset to the
  159. next string table. */
  160. stroff = next_stroff;
  161. next_stroff += value;
  162. }
  163. else
  164. {
  165. char *f, *s;
  166. f = NULL;
  167. s = (char *) strings + stroff + strx;
  168. while (s[strlen (s) - 1] == '\\'
  169. && stab + 12 < stabs + stabsize)
  170. {
  171. char *p;
  172. stab += 12;
  173. p = s + strlen (s) - 1;
  174. *p = '\0';
  175. s = concat (s,
  176. ((char *) strings
  177. + stroff
  178. + bfd_get_32 (abfd, stab)),
  179. (const char *) NULL);
  180. /* We have to restore the backslash, because, if
  181. the linker is hashing stabs strings, we may
  182. see the same string more than once. */
  183. *p = '\\';
  184. if (f != NULL)
  185. free (f);
  186. f = s;
  187. }
  188. save_stab (type, desc, value, s);
  189. if (! parse_stab (dhandle, shandle, type, desc, value, s))
  190. {
  191. #if 0
  192. /*
  193. * JZ: skip the junk.
  194. */
  195. stab_context ();
  196. free_saved_stabs ();
  197. return false;
  198. #endif
  199. }
  200. /* Don't free f, since I think the stabs code
  201. expects strings to hang around. This should be
  202. straightened out. FIXME. */
  203. }
  204. }
  205. free_saved_stabs ();
  206. free (stabs);
  207. /* Don't free strings, since I think the stabs code expects
  208. the strings to hang around. This should be straightened
  209. out. FIXME. */
  210. }
  211. }
  212. if (shandle != NULL)
  213. {
  214. if (! finish_stab (dhandle, shandle))
  215. return false;
  216. }
  217. return true;
  218. }
  219. /* Read stabs in the symbol table. */
  220. static boolean
  221. read_symbol_stabs_debugging_info (abfd, syms, symcount, dhandle, pfound)
  222. bfd *abfd;
  223. asymbol **syms;
  224. long symcount;
  225. PTR dhandle;
  226. boolean *pfound;
  227. {
  228. PTR shandle;
  229. asymbol **ps, **symend;
  230. shandle = NULL;
  231. symend = syms + symcount;
  232. for (ps = syms; ps < symend; ps++)
  233. {
  234. symbol_info i;
  235. bfd_get_symbol_info (abfd, *ps, &i);
  236. if (i.type == '-')
  237. {
  238. const char *s;
  239. char *f;
  240. if (shandle == NULL)
  241. {
  242. shandle = start_stab (dhandle, abfd, false, syms, symcount);
  243. if (shandle == NULL)
  244. return false;
  245. }
  246. *pfound = true;
  247. s = i.name;
  248. f = NULL;
  249. while (s[strlen (s) - 1] == '\\'
  250. && ps + 1 < symend)
  251. {
  252. char *sc, *n;
  253. ++ps;
  254. sc = xstrdup (s);
  255. sc[strlen (sc) - 1] = '\0';
  256. n = concat (sc, bfd_asymbol_name (*ps), (const char *) NULL);
  257. free (sc);
  258. if (f != NULL)
  259. free (f);
  260. f = n;
  261. s = n;
  262. }
  263. save_stab (i.stab_type, i.stab_desc, i.value, s);
  264. if (! parse_stab (dhandle, shandle, i.stab_type, i.stab_desc,
  265. i.value, s))
  266. {
  267. stab_context ();
  268. free_saved_stabs ();
  269. return false;
  270. }
  271. /* Don't free f, since I think the stabs code expects
  272. strings to hang around. This should be straightened out.
  273. FIXME. */
  274. }
  275. }
  276. free_saved_stabs ();
  277. if (shandle != NULL)
  278. {
  279. if (! finish_stab (dhandle, shandle))
  280. return false;
  281. }
  282. return true;
  283. }
  284. /* Read IEEE debugging information. */
  285. static boolean
  286. read_ieee_debugging_info (abfd, dhandle, pfound)
  287. bfd *abfd;
  288. PTR dhandle;
  289. boolean *pfound;
  290. {
  291. asection *dsec;
  292. bfd_size_type size;
  293. bfd_byte *contents;
  294. /* The BFD backend puts the debugging information into a section
  295. named .debug. */
  296. dsec = bfd_get_section_by_name (abfd, ".debug");
  297. if (dsec == NULL)
  298. return true;
  299. size = bfd_section_size (abfd, dsec);
  300. contents = (bfd_byte *) xmalloc (size);
  301. if (! bfd_get_section_contents (abfd, dsec, contents, 0, size))
  302. return false;
  303. if (! parse_ieee (dhandle, abfd, contents, size))
  304. return false;
  305. free (contents);
  306. *pfound = true;
  307. return true;
  308. }
  309. /* Record stabs strings, so that we can give some context for errors. */
  310. #define SAVE_STABS_COUNT (16)
  311. struct saved_stab
  312. {
  313. int type;
  314. int desc;
  315. bfd_vma value;
  316. char *string;
  317. };
  318. static struct saved_stab saved_stabs[SAVE_STABS_COUNT];
  319. static int saved_stabs_index;
  320. /* Save a stabs string. */
  321. static void
  322. save_stab (type, desc, value, string)
  323. int type;
  324. int desc;
  325. bfd_vma value;
  326. const char *string;
  327. {
  328. if (saved_stabs[saved_stabs_index].string != NULL)
  329. free (saved_stabs[saved_stabs_index].string);
  330. saved_stabs[saved_stabs_index].type = type;
  331. saved_stabs[saved_stabs_index].desc = desc;
  332. saved_stabs[saved_stabs_index].value = value;
  333. saved_stabs[saved_stabs_index].string = xstrdup (string);
  334. saved_stabs_index = (saved_stabs_index + 1) % SAVE_STABS_COUNT;
  335. }
  336. /* Provide context for an error. */
  337. static void
  338. stab_context ()
  339. {
  340. int i;
  341. fprintf (stderr, "Last stabs entries before error:\n");
  342. fprintf (stderr, "n_type n_desc n_value string\n");
  343. i = saved_stabs_index;
  344. do
  345. {
  346. struct saved_stab *stabp;
  347. stabp = saved_stabs + i;
  348. if (stabp->string != NULL)
  349. {
  350. const char *s;
  351. s = bfd_get_stab_name (stabp->type);
  352. if (s != NULL)
  353. fprintf (stderr, "%-6s", s);
  354. else if (stabp->type == 0)
  355. fprintf (stderr, "HdrSym");
  356. else
  357. fprintf (stderr, "%-6d", stabp->type);
  358. fprintf (stderr, " %-6d ", stabp->desc);
  359. fprintf_vma (stderr, stabp->value);
  360. if (stabp->type != 0)
  361. fprintf (stderr, " %s", stabp->string);
  362. fprintf (stderr, "\n");
  363. }
  364. i = (i + 1) % SAVE_STABS_COUNT;
  365. }
  366. while (i != saved_stabs_index);
  367. }
  368. /* Free the saved stab strings. */
  369. static void
  370. free_saved_stabs ()
  371. {
  372. int i;
  373. for (i = 0; i < SAVE_STABS_COUNT; i++)
  374. {
  375. if (saved_stabs[i].string != NULL)
  376. {
  377. free (saved_stabs[i].string);
  378. saved_stabs[i].string = NULL;
  379. }
  380. }
  381. saved_stabs_index = 0;
  382. }