暫無描述

addr2line 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/bash
  2. # Copyright 2014 Google Inc. All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #
  16. # addr2line stub for testing of addr2liner.
  17. # Will recognize (and ignore) the -aiCfej options.
  18. #
  19. # Accepts addresses 1000 to 9000 and output multiple frames of the form:
  20. # 0x9000/fun9000/file9000:9000
  21. # 0x8000/fun8000/file8000:8000
  22. # 0x7000/fun7000/file7000:7000
  23. # ...
  24. # 0x1000/fun1000/file1000:1000
  25. #
  26. # Returns ??/??/??:0 for all other inputs.
  27. while getopts aiCfe:j: opt; do
  28. case "$opt" in
  29. a|i|C|f|e|j) ;;
  30. *)
  31. echo "unrecognized option: $1" >&2
  32. exit 1
  33. esac
  34. done
  35. while read input
  36. do
  37. address="$input"
  38. # remove 0x from input.
  39. case "${address}" in
  40. 0x*)
  41. address=$(printf '%x' "$address")
  42. ;;
  43. *)
  44. address=$(printf '%x' "0x$address")
  45. esac
  46. printf '0x%x\n' "0x$address"
  47. loop=1
  48. while [ $loop -eq 1 ]
  49. do
  50. # prepare default output.
  51. output2="fun${address}"
  52. output3="file${address}:${address}"
  53. # specialize output for selected cases.
  54. case "${address}" in
  55. 1000)
  56. output2="_Z3fooid.clone2"
  57. loop=0
  58. ;;
  59. 2000)
  60. output2="_ZNSaIiEC1Ev.clone18"
  61. address=1000
  62. ;;
  63. 3000)
  64. output2="_ZNSt6vectorIS_IS_IiSaIiEESaIS1_EESaIS3_EEixEm"
  65. address=2000
  66. ;;
  67. [4-9]000)
  68. address=$(expr ${address} - 1000)
  69. ;;
  70. *)
  71. output2='??'
  72. output3='??:0'
  73. loop=0
  74. esac
  75. echo "$output2"
  76. echo "$output3"
  77. done
  78. done
  79. exit 0