• Jim Cromie's avatar
    dyndbg: gather __dyndbg[] state into struct _ddebug_info · b7b4eebd
    Jim Cromie authored
    This new struct composes the linker provided (vector,len) section,
    and provides a place to add other __dyndbg[] state-data later:
    
      descs - the vector of descriptors in __dyndbg section.
      num_descs - length of the data/section.
    
    Use it, in several different ways, as follows:
    
    In lib/dynamic_debug.c:
    
    ddebug_add_module(): Alter params-list, replacing 2 args (array,index)
    with a struct _ddebug_info * containing them both, with room for
    expansion.  This helps future-proof the function prototype against the
    looming addition of class-map info into the dyndbg-state, by providing
    a place to add more member fields later.
    
    NB: later add static struct _ddebug_info builtins_state declaration,
    not needed yet.
    
    ddebug_add_module() is called in 2 contexts:
    
    In dynamic_debug_init(), declare, init a struct _ddebug_info di
    auto-var to use as a cursor.  Then iterate over the prdbg blocks of
    the builtin modules, and update the di cursor before calling
    _add_module for each.
    
    Its called from kernel/module/main.c:load_info() for each loaded
    module:
    
    In internal.h, alter struct load_info, replacing the dyndbg array,len
    fields with an embedded _ddebug_info containing them both; and
    populate its members in find_module_sections().
    
    The 2 calling contexts differ in that _init deals with contiguous
    subranges of __dyndbgs[] section, packed together, while loadable
    modules are added one at a time.
    
    So rename ddebug_add_module() into outer/__inner fns, call __inner
    from _init, and provide the offset into the builtin __dyndbgs[] where
    the module's prdbgs reside.  The cursor provides start, len of the
    subrange for each.  The offset will be used later to pack the results
    of builtin __dyndbg_sites[] de-duplication, and is 0 and unneeded for
    loadable modules,
    
    Note:
    
    kernel/module/main.c includes <dynamic_debug.h> for struct
    _ddeubg_info.  This might be prone to include loops, since its also
    included by printk.h.  Nothing has broken in robot-land on this.
    
    cc: Luis Chamberlain <mcgrof@kernel.org>
    Signed-off-by: default avatarJim Cromie <jim.cromie@gmail.com>
    Link: https://lore.kernel.org/r/20220904214134.408619-12-jim.cromie@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    b7b4eebd
internal.h 8.61 KB