X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=lib%2Fvirt_mem_kallsyms.ml;h=9e6eccb6629a2ea067ee46a7c690aea17e44c0d2;hb=23d37ef6cec5003b63797343cf7f3bb75e915809;hp=87035e83b992fbdb9d3d1213891e7a3501b2a897;hpb=89d41f7614612cf991d6005e7c1e20cd502a5404;p=virt-mem.git diff --git a/lib/virt_mem_kallsyms.ml b/lib/virt_mem_kallsyms.ml index 87035e8..9e6eccb 100644 --- a/lib/virt_mem_kallsyms.ml +++ b/lib/virt_mem_kallsyms.ml @@ -36,7 +36,8 @@ type kallsyms_compr = | Compressed of (string * Virt_mem_mmap.addr) list * Virt_mem_mmap.addr | Uncompressed of (string * Virt_mem_mmap.addr) list -let find_kallsyms debug (domid, name, arch, mem, lookup_ksym) = +let find_kallsyms debug ({ domname = domname; mem = mem; ksyms = ksyms } + as kimage) = let start_t = gettimeofday () in (* Now try to find the /proc/kallsyms table. This is in an odd @@ -50,7 +51,7 @@ let find_kallsyms debug (domid, name, arch, mem, lookup_ksym) = * more useful than the basic list of exports. *) let ksym_addrs = List.filter_map ( - fun ksym -> try Some (lookup_ksym ksym) with Not_found -> None + fun ksym -> try Some (Ksymmap.find ksym ksyms) with Not_found -> None ) Virt_mem_ksyms.common_ksyms in (* Search for those kernel addresses in the image. We're looking @@ -70,7 +71,7 @@ let find_kallsyms debug (domid, name, arch, mem, lookup_ksym) = * If found, jump backwards by length and check all addresses. *) if debug then - eprintf "%s: testing candidate kallsyms at %Lx\n" name addr; + eprintf "%s: testing candidate kallsyms at %Lx\n" domname addr; let rec loop addr = let addrp = Virt_mem_mmap.follow_pointer mem addr in if Virt_mem_mmap.is_mapped mem addrp then @@ -100,7 +101,7 @@ let find_kallsyms debug (domid, name, arch, mem, lookup_ksym) = let names_addr = Virt_mem_mmap.succ_long mem end_addr in if debug then eprintf "%s: candidate kallsyms found at %Lx (names_addr at %Lx, num_entries %d)\n" - name start_addr names_addr num_entries; + domname start_addr names_addr num_entries; Some (start_addr, num_entries, names_addr) in loop2 start_addr @@ -180,7 +181,7 @@ let find_kallsyms debug (domid, name, arch, mem, lookup_ksym) = ) ksym_addrs in if debug then ( - eprintf "%s: candidate kallsyms at:\n" name; + eprintf "%s: candidate kallsyms at:\n" domname; List.iter ( function | (start_addr, num_entries, names_addr, Uncompressed _) -> @@ -196,23 +197,20 @@ let find_kallsyms debug (domid, name, arch, mem, lookup_ksym) = (* Vote for the most popular symbol table candidate and * enhance the function for looking up ksyms. *) - let lookup_ksym = + let ksyms, have_kallsyms = let freqs = frequency kallsymtabs in match freqs with | [] -> - (* Can't find any kallsymtabs, just return the lookup_ksym - * function generated previously from the exported symbols. - *) - lookup_ksym + (* Can't find any kallsymtabs. *) + ksyms, false | (_, (_, _, _, Uncompressed names)) :: _ -> - let lookup_ksym name = - try (* first look it up in kallsyms table. *) - List.assoc name names - with Not_found -> (* try the old exports table instead *) - lookup_ksym name + let rec loop ksyms = function + | (name, value) :: names -> + loop (Ksymmap.add name value ksyms) names + | [] -> ksyms in - lookup_ksym + loop ksyms names, true | (_, (start_addr, num_entries, names_addr, Compressed (compressed_names, markers_addr))) :: _ -> @@ -258,14 +256,12 @@ let find_kallsyms debug (domid, name, arch, mem, lookup_ksym) = Some (name, sym_value) ) compressed_names in - let lookup_ksym name = - try (* first look it up in kallsyms table. *) - List.assoc name names - with Not_found -> (* try the old exports table instead *) - lookup_ksym name + let rec loop ksyms = function + | (name, value) :: names -> + loop (Ksymmap.add name value ksyms) names + | [] -> ksyms in - - lookup_ksym in + loop ksyms names, true in if debug then ( let end_t = gettimeofday () in @@ -273,4 +269,4 @@ let find_kallsyms debug (domid, name, arch, mem, lookup_ksym) = (end_t -. start_t) ); - ((domid, name, arch, mem, lookup_ksym) : image1) + { kimage with ksyms = ksyms; have_kallsyms = have_kallsyms }