|
|||||||||||
|
Re: Debugging ld.so
From: Kurt Miller <truk(at)optonline.net>
Date: Tue Jul 08 2003 - 11:48:24 EDT
From: "Dale Rahn" <dalerahn@comcast.net>
I haven't had a chance to try your suggestions yet. My day job seems to be getting in the way of getting my preferred work done. ;-) However, my setup is as follows:
Change the ALL_TARGET from release-images to world-debug to build only the debug versions of the jdk. Place the following into the patches directory in the port:
patch-src_bsd_hpi_src_linker_md_c:
+#ifdef __ELF__
+ int tag;
+ Elf_Dyn *dp;
+ struct link_map *lm;
+ Elf_Ehdr *ehdr;
+ Elf_Phdr *phdr;
+ char *s;
+ int i;
+
+ for (dp = _DYNAMIC; (tag = dp->d_tag) != 0; dp++) {
+ if (tag == DT_DEBUG) {
+ lm = ((struct r_debug *)(dp->d_un.d_ptr))->r_map;
+ }
+ }
+
+ for (; lm != NULL; lm = lm->l_next) {
+ ehdr = (Elf_Ehdr *)lm->l_addr;
+ if (ehdr == NULL)
+ continue;
+
+ phdr = (Elf_Phdr *)((char *)lm->l_addr + ehdr->e_phoff);
+
+ for (i = 0; i < ehdr->e_phnum; i++) {
+ switch (phdr[i].p_type) {
+ case PT_LOAD:
+ s = (char *)phdr[i].p_vaddr + (int)lm->l_addr;
+ if (addr >= s && addr < s + phdr[i].p_memsz)
+ return lm->l_name;
+ break;
+ default:
+ }
+ }
+ }
+
+ return NULL;
+#else
struct so_map *so_map;
so_map = (struct so_map *)dlopen(0, RTLD_LAZY);
@@ -262,6 +298,7 @@ dlfname(const void *addr)
}
}
return so_map ? so_map->som_path : NULL;
+#endif
#else Obj_Entry * so_map; 3) Manually fetch the source from Sun and the BSD patchset from eyesbeyond as described in the port Makefile. Build the port and it will fail upon the first execution on javac_g.
4) I debug using the following .gdbinit file to save typing:
set environment
This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:48:42 EDT |
||||||||||
|
|||||||||||