summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorjwd <jwd@FreeBSD.org>2000-08-26 05:13:29 +0000
committerjwd <jwd@FreeBSD.org>2000-08-26 05:13:29 +0000
commitcb20a6ddc9987b9efc0c665c2af2bd20a72eaf1e (patch)
tree2bcf842471d4a4097888a6adadab4124bc7fce29 /libexec
parentabf2c201618e161195536aba27ea37a2cf60fad5 (diff)
downloadFreeBSD-src-cb20a6ddc9987b9efc0c665c2af2bd20a72eaf1e.zip
FreeBSD-src-cb20a6ddc9987b9efc0c665c2af2bd20a72eaf1e.tar.gz
Pass two pointer parameters to the r_debug_state() hook
function, thus allowing a debugger or other trace tool to easily grab the addresses of the needed structures off the stack. This change is transparent to gdb, which locates the link_map list and transfers it to debugger memory for comparison purposes. A sample program will be committed showing how this can be used. Reviewed by: John Polstra <jdp@FreeBSD.org>
Diffstat (limited to 'libexec')
-rw-r--r--libexec/rtld-elf/rtld.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 375ff79..4eba8e7 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -112,7 +112,7 @@ static void trace_loaded_objects(Obj_Entry *obj);
static void unload_object(Obj_Entry *);
static void unref_dag(Obj_Entry *);
-void r_debug_state(void);
+void r_debug_state(struct r_debug*, struct link_map*);
void xprintf(const char *, ...);
/*
@@ -144,7 +144,7 @@ static LockInfo lockinfo;
static Elf_Sym sym_zero; /* For resolving undefined weak refs. */
-#define GDB_STATE(s) r_debug.r_state = s; r_debug_state();
+#define GDB_STATE(s,m) r_debug.r_state = s; r_debug_state(&r_debug,m);
extern Elf_Dyn _DYNAMIC;
#pragma weak _DYNAMIC
@@ -392,7 +392,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
objlist_init(&initlist);
initlist_add_objects(obj_list, preload_tail, &initlist);
- r_debug_state(); /* say hello to gdb! */
+ r_debug_state(NULL, &obj_main->linkmap); /* say hello to gdb! */
objlist_call_init(&initlist);
wlock_acquire();
@@ -1498,9 +1498,9 @@ dlclose(void *handle)
objlist_remove_unref(&list_fini);
/* Finish cleaning up the newly-unreferenced objects. */
- GDB_STATE(RT_DELETE);
+ GDB_STATE(RT_DELETE,&root->linkmap);
unload_object(root);
- GDB_STATE(RT_CONSISTENT);
+ GDB_STATE(RT_CONSISTENT,NULL);
}
wlock_release();
return 0;
@@ -1546,7 +1546,7 @@ dlopen(const char *name, int mode)
objlist_init(&initlist);
wlock_acquire();
- GDB_STATE(RT_ADD);
+ GDB_STATE(RT_ADD,NULL);
old_obj_tail = obj_tail;
obj = NULL;
@@ -1581,7 +1581,7 @@ dlopen(const char *name, int mode)
}
}
- GDB_STATE(RT_CONSISTENT);
+ GDB_STATE(RT_CONSISTENT,obj ? &obj->linkmap : NULL);
/* Call the init functions with no locks held. */
wlock_release();
@@ -1766,9 +1766,19 @@ linkmap_delete(Obj_Entry *obj)
/*
* Function for the debugger to set a breakpoint on to gain control.
+ *
+ * The two parameters allow the debugger to easily find and determine
+ * what the runtime loader is doing and to whom it is doing it.
+ *
+ * When the loadhook trap is hit (r_debug_state, set at program
+ * initialization), the arguments can be found on the stack:
+ *
+ * +8 struct link_map *m
+ * +4 struct r_debug *rd
+ * +0 RetAddr
*/
void
-r_debug_state(void)
+r_debug_state(struct r_debug* rd, struct link_map *m)
{
}
OpenPOWER on IntegriCloud