From 00ee241553768a40a356208e0402fefb93a508bf Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 27 Mar 2012 13:51:45 -0500 Subject: Add example on SYSCTL_NODE expansion for _bsd_sysctl__net_children --- libbsd.txt | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'libbsd.txt') diff --git a/libbsd.txt b/libbsd.txt index 32e120ba..56b47f1a 100644 --- a/libbsd.txt +++ b/libbsd.txt @@ -272,3 +272,46 @@ time and the various initialization routines will thus be executed in' the correct order. XXX This needs more details. + +=== SYSCTL_NODE Example + +During development, we had an undefined reference to +_bsd_sysctl__net_children that we had trouble tracking down. Thanks to +Chris Johns, we located it. He explained how to read SYSCTL_NODE +definitions. This line from freebsd/netinet/in_proto.c is attempting +to add the "inet" node to the parent node "_net". + +[listing] +---- +SYSCTL_NODE(_net, PF_INET, inet, CTLFLAG_RW, 0, + "Internet Family"); +---- + +Our problem was that we could not find where _bsd_sysctl__net_children +was defined. Chris suggested that when in doubt compile with -save-temps +and look at the preprocessed .i files. But he did not need that. He +explained that this the symbol name _bsd_sysctl__net_children was +automatically generated by a SYSCTL_NODE as follows: + +* _bsd_ - added by RTEMS modifications to SYSCTL_NODE macro +* sysctl_ - boilerplace added by SYSCTL_NODE macro +* "" - empty string for parent node +* net - name of SYSCTL_NODE +* children - added by SYSCTL macros + +This was all generated by a support macro declaring the node as this: + +[listing] +---- +struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name); +---- + +Given this information, we located this SYSCTL_NODE declaration in +kern/kern_mib.c + +[listing] +---- +SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW, 0, + "High kernel, proc, limits &c"); +---- + -- cgit v1.2.3