git-afsantos / haros

H(igh) A(ssurance) ROS - Static analysis of ROS application code.
MIT License
190 stars 37 forks source link

Extractions of actions and its types #55

Closed ipa-nhg closed 4 years ago

ipa-nhg commented 5 years ago

The metamodel has to be updated to support the actions, this will be done on a separated PR as this one separately can't break HAROS (the functions are not been called).

The functions had been tested on a separated plugin using the following lines (that for HAROS have to be added/called here https://github.com/git-afsantos/haros/blob/master/haros/extractor.py#L802-L814):

for call in (CodeQuery(gs).all_calls.where_name("SimpleActionServer").get()):
  name = self._extract_action(call)
  action_type = self._extract_action_type(call)

for call in (CodeQuery(gs).all_calls.where_name("SimpleActionClient").get()):
  name = self._extract_action(call)
  action_type = self._extract_action_type(call)

Still some cases for Action Clients are not supported, for example when the ActionClient is declared with typdef. i.e. :

https://github.com/ros/common_tutorials/blob/indigo-devel/actionlib_tutorials/src/fibonacci_callback_client.cpp

https://github.com/ros/common_tutorials/blob/indigo-devel/actionlib_tutorials/src/fibonacci_class_client.cpp

Probably to support this cases bonsai has also to be updated.

git-afsantos commented 5 years ago

The metamodel has to be updated to support the actions, this will be done on a separated PR as this one separately can't break HAROS (the functions are not been called).

Good idea. That is probably more manageable than a monolithic PR. :+1:

The functions had been tested on a separated plugin using the following lines (that for HAROS have to be added/called here https://github.com/git-afsantos/haros/blob/master/haros/extractor.py#L802-L814):

for call in (CodeQuery(gs).all_calls.where_name("SimpleActionServer").get()):
  name = self._extract_action(call)
  action_type = self._extract_action_type(call)

for call in (CodeQuery(gs).all_calls.where_name("SimpleActionClient").get()):
  name = self._extract_action(call)
  action_type = self._extract_action_type(call)

It is unlikely that there are any more SimpleActionClients in user code besides the one from actionlib, but, out of curiosity, is there any reason for not including where_result("actionlib::SimpleActionClient") in the query? Is this related to the issue below?

Still some cases for Action Clients are not supported, for example when the ActionClient is declared with typdef.

Probably to support this cases bonsai has also to be updated.

I will give it a go to see what is going on.

git-afsantos commented 5 years ago

Probably to support this cases bonsai has also to be updated.

Yes, seems like it. Doing cppobj.result returns the typedef type, and not the original one. I have updated bonsai so that many C++ objects now have an additional canonical_type.

For reference: https://github.com/git-afsantos/bonsai/issues/14