script.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2001-2002 Hewlett-Packard Co
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
  4. This file is part of libunwind.
  5. Permission is hereby granted, free of charge, to any person obtaining
  6. a copy of this software and associated documentation files (the
  7. "Software"), to deal in the Software without restriction, including
  8. without limitation the rights to use, copy, modify, merge, publish,
  9. distribute, sublicense, and/or sell copies of the Software, and to
  10. permit persons to whom the Software is furnished to do so, subject to
  11. the following conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  21. #define IA64_LOG_UNW_CACHE_SIZE 7
  22. #define IA64_UNW_CACHE_SIZE (1 << IA64_LOG_UNW_CACHE_SIZE)
  23. #define IA64_LOG_UNW_HASH_SIZE (IA64_LOG_UNW_CACHE_SIZE + 1)
  24. #define IA64_UNW_HASH_SIZE (1 << IA64_LOG_UNW_HASH_SIZE)
  25. typedef unsigned char unw_hash_index_t;
  26. struct ia64_script_insn
  27. {
  28. unsigned int opc; /* see enum ia64_script_insn_opcode */
  29. unsigned int dst;
  30. unw_word_t val;
  31. };
  32. /* Updating each preserved register may result in one script
  33. instruction each. At the end of the script, psp gets popped,
  34. accounting for one more instruction. */
  35. #define IA64_MAX_SCRIPT_LEN (IA64_NUM_PREGS + 1)
  36. struct ia64_script
  37. {
  38. unw_word_t ip; /* ip this script is for */
  39. unw_word_t pr_mask; /* mask of predicates script depends on */
  40. unw_word_t pr_val; /* predicate values this script is for */
  41. unw_proc_info_t pi; /* info about underlying procedure */
  42. unsigned short lru_chain; /* used for least-recently-used chain */
  43. unsigned short coll_chain; /* used for hash collisions */
  44. unsigned short hint; /* hint for next script to try (or -1) */
  45. unsigned short count; /* number of instructions in script */
  46. unsigned short abi_marker;
  47. struct ia64_script_insn insn[IA64_MAX_SCRIPT_LEN];
  48. };
  49. struct ia64_script_cache
  50. {
  51. #ifdef HAVE_ATOMIC_OPS_H
  52. AO_TS_t busy; /* is the script-cache busy? */
  53. #else
  54. pthread_mutex_t lock;
  55. #endif
  56. unsigned short lru_head; /* index of lead-recently used script */
  57. unsigned short lru_tail; /* index of most-recently used script */
  58. /* hash table that maps instruction pointer to script index: */
  59. unsigned short hash[IA64_UNW_HASH_SIZE];
  60. uint32_t generation; /* generation number */
  61. /* script cache: */
  62. struct ia64_script buckets[IA64_UNW_CACHE_SIZE];
  63. };
  64. #define ia64_cache_proc_info UNW_OBJ(cache_proc_info)
  65. #define ia64_get_cached_proc_info UNW_OBJ(get_cached_proc_info)
  66. struct cursor; /* forward declaration */
  67. extern int ia64_cache_proc_info (struct cursor *c);
  68. extern int ia64_get_cached_proc_info (struct cursor *c);