/thirdparty/breakpad/processor/stackwalker_selftest_sol.s

http://github.com/tomahawk-player/tomahawk · Assembly · 111 lines · 57 code · 15 blank · 39 comment · 1 complexity · abe32d3ac5c40ab4d5cc1a20b11745a8 MD5 · raw file

  1. /* Copyright (c) 2007, Google Inc.
  2. * All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following disclaimer
  12. * in the documentation and/or other materials provided with the
  13. * distribution.
  14. * * Neither the name of Google Inc. nor the names of its
  15. * contributors may be used to endorse or promote products derived from
  16. * this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. */
  30. /* stackwalker_selftest_sol.s
  31. * On Solaris, the recommeded compiler is CC, so we can not use gcc inline
  32. * asm, use this method instead.
  33. *
  34. * How to compile: as -P -L -D_ASM -D_STDC -K PIC -o \
  35. * src/processor/stackwalker_selftest_sol.o \
  36. * src/processor/stackwalker_selftest_sol.s
  37. *
  38. * Author: Michael Shang
  39. */
  40. #include <sys/asm_linkage.h>
  41. #if defined(__i386)
  42. ENTRY(GetEBP)
  43. pushl %ebp
  44. movl %esp,%ebp
  45. subl $0x00000004,%esp
  46. movl 0x00000000(%ebp),%eax
  47. movl %eax,0xfffffffc(%ebp)
  48. movl 0xfffffffc(%ebp),%eax
  49. leave
  50. ret
  51. SET_SIZE(GetEBP)
  52. ENTRY(GetEIP)
  53. pushl %ebp
  54. movl %esp,%ebp
  55. subl $0x00000004,%esp
  56. movl 0x00000004(%ebp),%eax
  57. movl %eax,0xfffffffc(%ebp)
  58. movl 0xfffffffc(%ebp),%eax
  59. leave
  60. ret
  61. SET_SIZE(GetEIP)
  62. ENTRY(GetESP)
  63. pushl %ebp
  64. movl %esp,%ebp
  65. subl $0x00000004,%esp
  66. movl %ebp,%eax
  67. movl %eax,0xfffffffc(%ebp)
  68. movl 0xfffffffc(%ebp),%eax
  69. addl $0x00000008,%eax
  70. leave
  71. ret
  72. SET_SIZE(GetESP)
  73. #elif defined(__sparc)
  74. ENTRY(GetPC)
  75. save %sp, -120, %sp
  76. mov %i7, %i4
  77. inccc 8, %i4
  78. mov %i4, %i0
  79. ret
  80. restore
  81. SET_SIZE(GetPC)
  82. ENTRY(GetSP)
  83. save %sp, -120, %sp
  84. mov %fp, %i4
  85. mov %i4, %i0
  86. ret
  87. restore
  88. SET_SIZE(GetSP)
  89. ENTRY(GetFP)
  90. save %sp, -120, %sp
  91. ld [%fp + 56], %g1
  92. mov %g1, %i0
  93. ret
  94. restore
  95. SET_SIZE(GetFP)
  96. #endif // __i386 || __sparc