Project

General

Profile

Actions

Feature #3692

open

Add ability to get information on structure variable initialization

Added by Evgeny Novikov over 11 years ago. Updated about 8 years ago.

Status:
Open
Priority:
High
Category:
Weaving
Start date:
11/16/2012
Due date:
% Done:

0%

Estimated time:
Published in build:
e28f037

Description

So, having such the initialization of global variable with structure type:
static struct usb_driver karma_driver = {
        .name =         "ums-karma",
        .probe =        karma_probe,
        .disconnect =   usb_stor_disconnect,
        .suspend =      usb_stor_suspend,
        .resume =       usb_stor_resume,
        .reset_resume = usb_stor_reset_resume,
        .pre_reset =    usb_stor_pre_reset,
        .post_reset =   usb_stor_post_reset,
        .id_table =     karma_usb_ids,
        .soft_unbind =  1,
        .no_dynamic_id = 1,
};

we would like to obtain following information:
  1. "usb_driver" - structure name.
  2. "karma_driver" - variable name.
  3. "probe - karma_probe", ..., "post_reset - usb_stor_post_reset" - pairs of field name and function name (strings, numbers, variable names and so on are of no interest).

Files

test9.c (390 Bytes) test9.c Evgeny Novikov, 03/14/2013 02:19 PM
test9.aspect (243 Bytes) test9.aspect Evgeny Novikov, 03/14/2013 02:19 PM
file (1.17 KB) file Evgeny Novikov, 03/14/2013 02:19 PM
problems_acpi.tar.gz (167 KB) problems_acpi.tar.gz Ilja Zakharov, 03/18/2013 05:10 PM
problems_drbd.tar.gz (342 KB) problems_drbd.tar.gz Ilja Zakharov, 03/18/2013 05:10 PM
test9.c (777 Bytes) test9.c Evgeny Novikov, 03/19/2013 02:00 PM
test9.aspect (682 Bytes) test9.aspect Evgeny Novikov, 03/19/2013 02:00 PM
file (4.61 KB) file Evgeny Novikov, 03/19/2013 02:00 PM
ipmi_poweroff.c.macroinstrumented.xz (110 KB) ipmi_poweroff.c.macroinstrumented.xz Evgeny Novikov, 02/14/2014 12:42 PM
first_request.aspect.xz (612 Bytes) first_request.aspect.xz Evgeny Novikov, 02/14/2014 12:42 PM
first_request.answer.xz (764 Bytes) first_request.answer.xz Evgeny Novikov, 02/14/2014 12:42 PM

Related issues 1 (0 open1 closed)

Blocks C Instrumentation Framework - Feature #2959: We need to develop analyzer on the basis of CIF infrastructure for the new environment generatorClosedEvgeny Novikov06/06/2012

Actions

Updated by Evgeny Novikov about 11 years ago

First version of this feature is available in commit 693bb78 of feature-3692 branch pushed to Aspectator submodule. You can consider results (file file) obtained for file test9.c and aspect test9.aspect as output format specification. Note that initialization of arrays of structures isn't supported still.

Updated by Ilja Zakharov about 11 years ago

The following bugs occur while using this inforequest. More details in attachments.

Actions #3

Updated by Evgeny Novikov about 11 years ago

As for acpi, there turns out to be an array field name in acpi_driver structure. Beginning from commit 716a543 in feature-3692 branch information on it is printed in such the form:

Field name is 'name'
Field type is 'array'
Field declaration is 'char %s[80]'
Field value is '"processor_aggregator"'

As for drbd, unsupported array elements initialization was found:
struct dma_attrs attrs = { .flags = { [0 ... (((DMA_ATTR_MAX) + (8 * sizeof(long)) - 1) / (8 * sizeof(long)))-1] = 0 }, };

Updated by Evgeny Novikov about 11 years ago

Beginning from commit 00b8e7f in feature-3692 branch of Aspectator submodule initialization of simple/pointer/array variables is also supported. Also one can use "$" instead of array size in pointcuts to match arrays of any size.

These features required considerable changes in format, sorry for that. You can see new "specification" in attached files. I hope that they won't be changed so much in future.

BTW, drbd is processed well now.

Actions #5

Updated by Evgeny Novikov almost 11 years ago

  • Status changed from Feedback to Resolved
  • Published in build set to e28f037

Added in commit e28f037 of the master branch of LDV tools, in e0b4bea of CIF submodule and in commit bfe8a89 of Aspectator submodule.
Wait for night tests and reference launch results before closing.

Actions #6

Updated by Evgeny Novikov almost 11 years ago

  • Status changed from Resolved to Closed

Works fine for small and night regression tests as well as with reference launches for 32_7a rule model.

Updated by Evgeny Novikov about 10 years ago

One unpleasant issue was discovered. If a function pointer is assigned to a structure field but a type of this structure field doesn't coincide with a type of the given function, then the compiler makes an explicit cast on assignment. When we try to call functions together with these casts the compiler inserts __builtin_trap instead these calls, that eventually causes failures.

To reproduce this you need to run (CIF before 63912d):

$(CIF) --aspect first_request.aspect --in ipmi_poweroff.c.macroinstrumented --out out --stage instrumentation

and then you can see in first_request.answer:
Structure field initialization
  Field name is 'set'
  Type is 'function pointer'
  Declaration is 'int (*%s)(char const *, struct kernel_param const *)'
  Pointed function return type declaration is 'int %s'
  Pointed function argument type declarations are 'char const *%s', 'struct kernel_param const *%s'
  Value is '( int (*)(char const *, struct kernel_param const *)) & set_param_ifnum'

Although these issues are issues in drivers and thus should be fixed there, we can't wait when this will be done. And sometimes that mechanism is used intentionally, e.g. to assign pointers to stub functions. The compiler doesn't complain about that.

I am going to implement a workaround - will disable printing of casts in corresponding cases. No regexps!

Actions #8

Updated by Evgeny Novikov about 10 years ago

  • Status changed from Open to Feedback

Fixed in the feature-3692 branch of the Aspectator submodule. The workaround touches, by the way, all other implicit/explicit casts as well. This should simplify parsing of source code querying answers, but may be a source of other issues. So, I am looking forward for a feedback from Ilja. For instance, regressions for all modules for one rule specifications and for modules subjected to the given issue for other rule specifications.

Actions #9

Updated by Ilja Zakharov about 10 years ago

Application of the workaround during 3.13-rc1 kernel verification showed that in general benchmark was successful, but several problems occured. For instance, in case of function with void argument I got "error: too many arguments":

static enum xp_retval xpc_notloaded(void)

This function is used as follows:

struct xpc_interface xpc_interface = {
(void ()(int))xpc_notloaded,
(void (
)(int))xpc_notloaded,
(enum xp_retval()(short, int, u32, void *, u16))xpc_notloaded,
(enum xp_retval(
)(short, int, u32, void , u16, xpc_notify_func,
void *))xpc_notloaded,
(void (
)(short, int, void ))xpc_notloaded,
(enum xp_retval(
)(short, void *))xpc_notloaded
};
EXPORT_SYMBOL_GPL(xpc_interface);

DEG generates code according to structure fields:

(& xpc_notloaded)(ldvarg18);
...
(& xpc_notloaded)(ldvarg15,ldvarg17,ldvarg16);

Less than a dozen of modules failed because of the reason.

Actions #10

Updated by Evgeny Novikov about 10 years ago

  • Status changed from Feedback to Open
  • Priority changed from High to Normal

Reduce priority due to major issues were gone.

Actions #11

Updated by Evgeny Novikov about 8 years ago

  • Category set to Weaving
  • Priority changed from Normal to High
Actions

Also available in: Atom PDF