git.annexia.org
/
virt-mem.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated kerneldb.
[virt-mem.git]
/
lib
/
virt_mem_kallsyms.ml
diff --git
a/lib/virt_mem_kallsyms.ml
b/lib/virt_mem_kallsyms.ml
index
87035e8
..
9e6eccb
100644
(file)
--- 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
| 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
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 (
* 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
) 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
* 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"
dom
name addr;
let rec loop addr =
let addrp = Virt_mem_mmap.follow_pointer mem addr in
if Virt_mem_mmap.is_mapped mem addrp then
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"
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;
+
dom
name start_addr names_addr num_entries;
Some (start_addr, num_entries, names_addr)
in
loop2 start_addr
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 (
) ksym_addrs in
if debug then (
- eprintf "%s: candidate kallsyms at:\n" name;
+ eprintf "%s: candidate kallsyms at:\n"
dom
name;
List.iter (
function
| (start_addr, num_entries, names_addr, Uncompressed _) ->
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.
*)
(* 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
| [] ->
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)) :: _ ->
| (_, (_, _, _, 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
in
- loo
kup_ksym
+ loo
p ksyms names, true
| (_, (start_addr, num_entries, names_addr,
Compressed (compressed_names, markers_addr))) :: _ ->
| (_, (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
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
in
-
- lookup_ksym in
+ loop ksyms names, true in
if debug then (
let end_t = gettimeofday () 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)
);
(end_t -. start_t)
);
- ((domid, name, arch, mem, lookup_ksym) : image1)
+ { kimage with ksyms = ksyms; have_kallsyms = have_kallsyms }