[panda-users] problems with plugin api calls

Manolis Stamatogiannakis mstamat at gmail.com
Mon Apr 20 14:46:03 EDT 2015


2015-04-20 6:05 GMT-07:00 Leek, Timothy - 0559 - MITLL <tleek at ll.mit.edu>:

> HI Manolis.  If I understand correctly, you are having trouble b/c your
> plugin B is composed of multiple .c / .cpp files.  Yes?  I think that isn’t
> something we considered.  So, yes, a bug of sorts.
>

Yes, this is the case. Thanks for confirming.


>
> We tend to write small plugins or are content to have the code all
> squished into a single file.  And then we compose the plugins.   For
> instance, the tainted_instructions plugin is very small.  And useless on
> its own (since nothing ever gets labeled).  But paired with file_taint or
> tstringsearch + string search, it can do something.   One solution would be
> to conceive of your analysis as distributed across a few plugins.
>
> Or I think it would all work if you just sure that that code that needs
> the other plugin’s functionality is limited to one source file in your
> plugin.
>
> Ok, this makes it sound like we designed things this way.  That’s not
> true.  I, at least, was aware of this issue/limitation but didn’t consider
> it worth the extra software engineering.  So, yes, we are lazy and prefer
> using PANDA to software engineering it.  Sorry!
>
> I don’t have a solution ready at hand for your problem, but we will think
> about it.  You got any ideas that aren’t too ugly or painful?
>


I understand this is an oversight (nobody needed this until now) rather
than a design decision.

I was able to overcome the problem by also making the inlines inside the
auto-generated header static. This way they operate on the
source-file-specific instance of the static function pointer variable. See:
https://github.com/m000/panda/commit/5b6573274f34ea9f368b7da88272c035f238dcd4
Each source-file is still responsible to seperately initialize any APIs it
uses. But this wouldn't be much of a problem as PANDA plugins don't usually
grow big.
This is not very ugly (I think) and shoulnd't affect the operation of other
plugins in the pipeline (mine is: osi;osi_linux;other_plugin). If this
looks ok, you can cherry-pick the commit. Or I can make a pull request
later.

A "better" fix (from the engineering perspective :)) would involve (a)
Changing the static function pointers definition to extern declarations.
(b) Generating an additional header with the definitions of the externs.
The header would have to be included by the "main" module of the plugin.
But I would agree with you that this is probably too much engineering for
something that is not the common case in PANDA's usage.

Cheers,
Manolis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.mit.edu/pipermail/panda-users/attachments/20150420/59e5921e/attachment.htm


More information about the panda-users mailing list