After r354895, vm_map_entry has no longer prev/next fields. # cd /usr/ports/sysutils/lsof # make ===> Building for lsof-4.93.2_5,8 ..(snip).. --- dproc.o --- dproc.c:693:23: error: no member named 'next' in 'struct vm_map_entry' if (!(ka = (KA_T)e->next)) ~ ^ 1 error generated. *** [dproc.o] Error code 1 make[1]: stopped in /usr/ports/sysutils/lsof/work/lsof-4.93.2
Created attachment 209929 [details] use left instead of next in vm_map_entry I don't know we can use left instead of next in vm_map_entry.
@markj, @jhb, Can either of you help me here? Or suggest someone else?
(In reply to Masachika ISHIZUKA from comment #1) Do you mean "My last OK build was r354895 (r354894?)?" Element "next" in struct vm_map_entry is integrated with "right" at r355491, in conjunction with integrating "prev" to "left". So you should use "right" instead of "left". Related portion of diff is shown below. Modified: head/sys/vm/vm_map.h ============================================================================== --- head/sys/vm/vm_map.h Sat Dec 7 17:10:03 2019 (r355490) +++ head/sys/vm/vm_map.h Sat Dec 7 17:14:33 2019 (r355491) @@ -99,10 +99,8 @@ union vm_map_object { * Also included is control information for virtual copy operations. */ struct vm_map_entry { - struct vm_map_entry *prev; /* previous entry */ - struct vm_map_entry *next; /* next entry */ - struct vm_map_entry *left; /* left child in binary search tree */ - struct vm_map_entry *right; /* right child in binary search tree */ + struct vm_map_entry *left; /* left child or previous entry */ + struct vm_map_entry *right; /* right child or next entry */ vm_offset_t start; /* start address */ vm_offset_t end; /* end address */ vm_offset_t next_read; /* vaddr of the next sequential read */ It would be better converting to use vm_map_entry_read_succ() introduced at r355538. Related (non-reverted) commits: r355491: https://lists.freebsd.org/pipermail/svn-src-head/2019-December/131611.html r355538: https://lists.freebsd.org/pipermail/svn-src-head/2019-December/131642.html
Created attachment 209931 [details] use right instead of next in vm_map_entry Thank you Tomoaki AOKI. > Do you mean "My last OK build was r354895 (r354894?)?" > Element "next" in struct vm_map_entry is integrated with "right" at r355491, >in conjunction with integrating "prev" to "left". I'm sorry, you are correct. I checked 'https://svnweb.freebsd.org/base/head/sys/vm/vm_map.h?r1=354895&r2=355491' and misstyped previous version number.
(In reply to Masachika ISHIZUKA from comment #4) The patch isn't right, you need to use the vm_map_entry_succ() function now. Take a look at r355538, which made the same change for libprocstat.
(In reply to Mark Johnston from comment #5) Thank you for reply. It is hard to me to create correct patch. Is there anyone who can create patch ?
Created attachment 210006 [details] patch Not sure I got this right, at least it doesn't segfault. It should only be applied on -current.
(In reply to mikael.urankar from comment #7) This is a step in the right direction, but not quite right: kvm_read() returns the number of bytes read, and -1 upon an error. The reader function should compare the return value of kvm_read() with sizeof(*dest). The function should probably also be named something else, since it has nothing to do with procstat. vm_map_reader() is probably fine.
(In reply to Mark Johnston from comment #8) vm_map_entry_read_succ modifies the vm_map_entry struct that its second argument points to, by (generally) kvm-reading a new value into it. So this patch appears to modify vmsp.vm_map_header on iteration i==1. I suggest something like vmme = vmsp.vm_map_header; e = &vmme; to get started.
I would *REALLY* love some support from the kernel folks in getting lsof up to snuff with the current changes. I'm not a great C programmer, and the changes are significant. THere's also a great opportunity now to clean up all the way old cruft, but I'm *NOT* the person to do that. https://github.com/lsof-org/lsof
A commit references this bug: Author: ler Date: Sat Dec 21 02:01:52 UTC 2019 New revision: 520539 URL: https://svnweb.freebsd.org/changeset/ports/520539 Log: sysutils/lsof: unbreak after base r354895. - fix vm_map related breakage - remove #define/#undef _KERNEL for tmpfs (dougm had the header fixed) patch courtesy of dougm@ PR: 242620 Reported by: ish@amail.plala.or.jp Obtained from: dougm Changes: head/sysutils/lsof/Makefile head/sysutils/lsof/files/patch-dialects_freebsd_dnode.c head/sysutils/lsof/files/patch-dialects_freebsd_dproc.c
dougm@ gave me a patch that I just committed.