[DTrace-devel] [External] : [PATCH 1/7] libproc: keep the file offset of each mapping

Eslam Almorshdy via B4 Relay devnull+ealmorshdy.d-matrix.ai at kernel.org
Thu Oct 15 03:53:41 UTC 2026


From: Eslam Almorshdy <ealmorshdy at d-matrix.ai>

Pupdate_maps() parses the offset field of /proc/<pid>/maps but discards
it.  Store it in a new member, prmap_t.pr_offset: uprobes are placed by
(inode, file offset), so converting a runtime address to a uprobe offset
needs the file offset of the mapping that contains the address.

No functional change.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Eslam Almorshdy <ealmorshdy at d-matrix.ai>
---
 include/sys/sol_procfs.h | 1 +
 libproc/Psymtab.c        | 1 +
 2 files changed, 2 insertions(+)

diff --git a/include/sys/sol_procfs.h b/include/sys/sol_procfs.h
index 49eb29fb..52360f2d 100644
--- a/include/sys/sol_procfs.h
+++ b/include/sys/sol_procfs.h
@@ -42,6 +42,7 @@ typedef struct prmap {
 	uintptr_t pr_vaddr;	/* virtual address of mapping */
 	char	*pr_mapaddrname; /* address text from /proc/<pid>/maps */
 	size_t	pr_size;	/* size of mapping in bytes */
+	uint64_t pr_offset;	/* offset of the mapping in the backing file */
 	int	pr_mflags;	/* protection and attribute flags (see below) */
 	dev_t	pr_dev;		/* device number */
 	ino_t	pr_inum;	/* inode number */
diff --git a/libproc/Psymtab.c b/libproc/Psymtab.c
index e648c5aa..7876e9a8 100644
--- a/libproc/Psymtab.c
+++ b/libproc/Psymtab.c
@@ -639,6 +639,7 @@ Pupdate_maps(struct ps_prochandle *P)
 
 		pmptr->pr_vaddr = laddr;
 		pmptr->pr_size = haddr - laddr;
+		pmptr->pr_offset = offset;
 		pmptr->pr_mapaddrname = mapaddrname;
 
 		/*

-- 
2.55.0





More information about the DTrace-devel mailing list