tracking uninitialized static variables

后端 未结 5 497
孤街浪徒
孤街浪徒 2021-01-12 11:40

I need to debug an ugly and huge math C library, probably once produced by f2c. The code is abusing local static variables, and unfortunately somewhere it seems to

5条回答
  •  Happy的楠姐
    2021-01-12 12:08

    I don't know of any library that does this for you, but I would look into using regular expressions to find them. Something like

    rgrep "static\s*int" path/to/src/root | grep -v = | grep -v "("

    That should return all static int variables declared without an equals sign, and the last pipe should remove anything with parenthesis in them (getting rid of funcions). There's a good change that this won't work exactly for you, but playing around with grep may be the fastest way for you to track this down.

    Of course, once you find one that works you can replace int with all of the other kinds of variables to search for those too. HTH

提交回复
热议问题