[Crash-utility] [PATCH] load_module_symbols_helper().

Toshikazu Nakayama nakayama.ts at ncos.nec.co.jp
Thu Jan 20 05:09:46 UTC 2011


Hi Dave,

>This patch has way too much duplication of effort. 
>
>For example, why not do something simple like this in kernel.c?:
>
>diff -r1.244 kernel.c
>3626a3627,3640
>> int
>> load_module_symbols_helper(char *name)
>> {
>>       char *objfile;
>>       ulong address;
>> 
>>       if (is_module_name(name, &address, NULL) &&
>>           (objfile = find_module_objfile(name, NULL, NULL))) {
>>               do_module_cmd(LOAD_SPECIFIED_MODULE_SYMBOLS, name, address, objfile, NULL);
>>               return TRUE;
>>       }
>>       return FALSE;
>> }
>> 

I wish I could have noticed beforehand.
I implemented this API in extension module inside at first.
(oops, I did ignore about directly using crash static functions.)

The crash utility already has similar functions to my patch
and those can provide much advanced functionalities.
I'll rework this patch with your example (completely the same).

>And verified that it works like so:
>
>  crash> test ext3
>       MODULE       NAME                        SIZE  OBJECT FILE
>  ffffffff8806ae00  ext3                      168017  /lib/modules/2.6.18-128.el5/kernel/fs/ext3/ext3.ko 
>  crash>

>Then you could also apply your "CRASH_MODULE_PATH" concept to
>the module_objfile_search() function, which does the same kind
>of thing for the various possible directory trees.  That way, 
>the non-standard CRASH_MODULE_PATH could be used by the "mod"
>command as well.

I will apply "CRASH_MODULE_PATH" next to DEFAULT_REDHAT_DEBUG_LOCATION search.

Thanks,
Toshi.

>Dave
>
> 
>> ----------------------------------------------------------
>> [ Test code image ]
>> 
>> #include <defs.h>
>> 
>> static int kvm_done, kvm_intel_done;
>> 
>> void kvm_symbol_setup(void)
>> {
>> /* dummy: structs or global symbols of KVM initilize */
>> kvm_done = 1;
>> }
>> 
>> void kvm_intel_symbol_setup(void)
>> {
>> /* dummy: structs or global symbols of VMX initilize */
>> kvm_intel_done = 1;
>> }
>> 
>> static void __attribute__((constructor))
>> module_load_test(void)
>> {
>> int ikconfig;
>> 
>> read_in_kernel_config(IKCFG_SETUP);
>> 
>> ikconfig = get_kernel_config("KVM", NULL);
>> if (ikconfig == IKCONFIG_Y)
>> kvm_symbol_setup();
>> else if (ikconfig == IKCONFIG_M)
>> if (load_module_symbols_helper("kvm", "arch/x86/kvm"))
>> kvm_symbol_setup();
>> 
>> ikconfig = get_kernel_config("KVM_INTEL", NULL);
>> if (ikconfig == IKCONFIG_Y)
>> kvm_intel_symbol_setup();
>> else if (ikconfig == IKCONFIG_M)
>> if (load_module_symbols_helper("kvm-intel", "arch/x86/kvm"))
>> kvm_intel_symbol_setup();
>> 
>> if (kvm_done)
>> fprintf(fp, "kvm module symbols loaded\n");
>> 
>> if (kvm_intel_done)
>> fprintf(fp, "kvm-intel module symbols loaded\n");
>> }
>> 
>> static void __attribute__((destructor))
>> module_load_test_fin(void)
>> {
>> read_in_kernel_config(IKCFG_FREE);
>> }
>> 
>> [ Result ]
>> crash> mod | grep kvm
>> ffffffffa008dba0 kvm 175160 (not loaded) [CONFIG_KALLSYMS]
>> ffffffffa00a4c40 kvm_intel 39368 (not loaded) [CONFIG_KALLSYMS]
>> 
>> crash> extend test.so
>> kvm module symbols loaded
>> kvm-intel module symbols loaded
>> extend: ./test.so: no commands registered: shared object unloaded
>> 
>> crash> mod | grep kvm
>> ffffffffa008dba0 kvm 175160
>> /lib/modules/2.6.35/kernel/arch/x86/kvm/kvm.ko
>> ffffffffa00a4c40 kvm_intel 39368
>> /lib/modules/2.6.35/kernel/arch/x86/kvm/kvm-intel.ko
>> 
>> 
>> Toshikazu Nakayama (1):
>> Add helper routine for load_module_symbols().
>> 
>> crash-5.1.1/defs.h | 1 +
>> crash-5.1.1/symbols.c | 89
>> +++++++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 90 insertions(+), 0 deletions(-)
>> 
>> --
>> 1.7.4.rc2
>> 
>> 
>> 
>> --
>> Crash-utility mailing list
>> Crash-utility at redhat.com
>> https://www.redhat.com/mailman/listinfo/crash-utility
>
>--
>Crash-utility mailing list
>Crash-utility at redhat.com
>https://www.redhat.com/mailman/listinfo/crash-utility




More information about the Crash-utility mailing list