os-hpux.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2003-2005 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. #include <dlfcn.h>
  22. #include <string.h>
  23. #include <unistd.h>
  24. #include "libunwind_i.h"
  25. #include "elf64.h"
  26. HIDDEN int
  27. tdep_get_elf_image (struct elf_image *ei, pid_t pid, unw_word_t ip,
  28. unsigned long *segbase, unsigned long *mapoff,
  29. char *path, size_t pathlen)
  30. {
  31. struct load_module_desc lmd;
  32. const char *path2;
  33. if (pid != getpid ())
  34. {
  35. printf ("%s: remote case not implemented yet\n", __FUNCTION__);
  36. return -UNW_ENOINFO;
  37. }
  38. if (!dlmodinfo (ip, &lmd, sizeof (lmd), NULL, 0, 0))
  39. return -UNW_ENOINFO;
  40. *segbase = lmd.text_base;
  41. *mapoff = 0; /* XXX fix me? */
  42. path2 = dlgetname (&lmd, sizeof (lmd), NULL, 0, 0);
  43. if (!path2)
  44. return -UNW_ENOINFO;
  45. if (path)
  46. {
  47. strncpy(path, path2, pathlen);
  48. path[pathlen - 1] = '\0';
  49. if (strcmp(path, path2) != 0)
  50. Debug(1, "buffer size (%d) not big enough to hold path\n", pathlen);
  51. }
  52. Debug(1, "segbase=%lx, mapoff=%lx, path=%s\n", *segbase, *mapoff, path);
  53. return elf_map_image (ei, path);
  54. }