[DTrace-devel] [PATCH 05/10] dtrace provider: don't use functions from uprobes.h any more
Nick Alcock
nick.alcock at oracle.com
Wed Aug 2 13:26:55 UTC 2023
This is about to go away, so the justification for using it (to make sure it
was frequently used and didn't rust) no longer applies.
This more or less reverts 5b43ff17f839195a29cadf255a947514d15aa478.
Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
---
libdtrace/dt_prov_dtrace.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/libdtrace/dt_prov_dtrace.c b/libdtrace/dt_prov_dtrace.c
index 474274558be3..a5c07733479a 100644
--- a/libdtrace/dt_prov_dtrace.c
+++ b/libdtrace/dt_prov_dtrace.c
@@ -16,7 +16,6 @@
#include "dt_cg.h"
#include "dt_provider_tp.h"
#include "dt_probe.h"
-#include "uprobes.h"
static const char prvname[] = "dtrace";
static const char modname[] = "";
@@ -172,8 +171,9 @@ static char *uprobe_spec(const char *prb)
struct ps_prochandle *P;
int perr = 0;
char *fun;
- char *spec = NULL;
GElf_Sym sym;
+ prsyminfo_t si;
+ char *spec = NULL;
if (asprintf(&fun, "%s%s", prb, PROBE_FUNC_SUFFIX) < 0)
return NULL;
@@ -185,10 +185,22 @@ static char *uprobe_spec(const char *prb)
return NULL;
}
- /* look up function and thus addr */
- if (Pxlookup_by_name(P, -1, PR_OBJ_EVERY, fun, &sym, NULL) == 0)
- spec = uprobe_spec_by_addr(P, sym.st_value, NULL);
+ /* look up function, get the map, and record */
+ if (Pxlookup_by_name(P, -1, PR_OBJ_EVERY, fun, &sym, &si) == 0) {
+ const prmap_t *mapp;
+ mapp = Paddr_to_map(P, sym.st_value);
+ if (mapp == NULL)
+ goto out;
+
+ if (mapp->pr_file->first_segment != mapp)
+ mapp = mapp->pr_file->first_segment;
+
+ asprintf(&spec, "%s:0x%lx", mapp->pr_file->prf_mapname,
+ sym.st_value - mapp->pr_vaddr);
+ }
+
+out:
free(fun);
Prelease(P, PS_RELEASE_NORMAL);
Pfree(P);
--
2.41.0.270.g68fa1d84b5
More information about the DTrace-devel
mailing list