Author Topic: Code static analysis and optimization tools  (Read 1057 times)

bpv5P

  • Member
  • ***
  • Posts: 169
Code static analysis and optimization tools
« on: August 08, 2017, 09:48:11 AM »
I don't know if the dev team is aware (probably is), but maybe some tools could help with ML testing and optimization. For example, the LLVM static analysis, Frama-C, splint, Valgrind (for memory) and Coverity:
http://www.frama-c.com/
http://www.splint.org/
http://valgrind.org/
https://www.coverity.com/

Got those tips from BCHS:
https://learnbchs.org/tools.html

Also, a question: I know it's trivial, but why use Bitbucket? Wouldn't it be a good practice to setup a project's own git? Since it has few commits, there's no need to pay a dedicated server, any laptop could run it...
https://git.zx2c4.com/cgit/about/


PS: sorry, if it's a duplicated thread please merge, I've not searched on this forum for previous threads on this subject.
PS: also, sorry for flooding this sub-board with two consecutive threads... too much coffee, I think. Wish I could help with this project, instead of giving awful ideas.

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 10553
  • 5D Mark Free
Re: Code static analysis and optimization tools
« Reply #1 on: August 08, 2017, 10:35:05 AM »
Valgrind: good luck porting it. I had an attempt to write a similar tool in QEMU (-d memchk), and already found a couple of bugs. It's currently working only on 500D.

Very easy coding task: port it to other models (it's mostly a matter of copy/paste and testing, with some stubs to find). Sorry, time is an issue on my side.

I've also played a bit with code coverage:
- with gcov: the size overhead is significant (autoexec.bin would grow very large, but it's probably doable for small modules)
- with QEMU: I've got a code coverage report from an execution trace (with qemu-etrace and Xilinx QEMU); also tried Project Couverture but could not get it to work.

I've also tried to use LLVM's thread safety analysis, but I need help (I'm not grasping these concepts very well).

Another suggestion I've got was to use openQA for automating ML testing in QEMU. I've got the backend installed (os-autoinst), but didn't figure out the web interface yet; help is welcome with this one as well (it's probably straightforward, but takes time). The emulator already runs unmodified ML binaries on most cameras. A long time ago, when we could barely emulate ML menu navigation (without much Canon code), I've suggested a visual diff for menu screenshots, but apparently it fell on deaf ears.

I'm not familiar with the other tools, but contributions (on applying them to ML) are welcome.

g3gg0

  • Developer
  • Hero Member
  • *****
  • Posts: 3054
Re: Code static analysis and optimization tools
« Reply #2 on: August 08, 2017, 04:54:11 PM »
about bitbucket: it's free for us iirc.
Help us with datasheets - Help us with register dumps
magic lantern: 1Magic9991E1eWbGvrsx186GovYCXFbppY, server expenses: [email protected]
ONLY donate for things we have done, not for things you expect!

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 10553
  • 5D Mark Free
Re: Code static analysis and optimization tools
« Reply #3 on: August 08, 2017, 05:38:53 PM »
Right - Trammell used Bitbucket when he started the project, and we had no good reason to change it.

bpv5P

  • Member
  • ***
  • Posts: 169
Re: Code static analysis and optimization tools
« Reply #4 on: August 10, 2017, 05:50:19 AM »
Valgrind: good luck porting it. I had an attempt to write a similar tool in QEMU (-d memchk), and already found a couple of bugs. It's currently working only on 500D.

I'll see if I can find an alternative...

Quote
I'm not familiar with the other tools, but contributions (on applying them to ML) are welcome.

The "splint" linked above is really simple to use., it may be worth your time:
http://www.splint.org/

a1ex

  • Administrator
  • Hero Member
  • *****
  • Posts: 10553
  • 5D Mark Free
Re: Code static analysis and optimization tools
« Reply #5 on: August 10, 2017, 10:37:00 AM »
The "splint" linked above is really simple to use., it may be worth your time:
http://www.splint.org/

Code: [Select]
... magic-lantern/modules/mlv_lite $ splint mlv_lite.c -I../../src -I../../platform/all -I.
...
/usr/include/bits/types.h:30:8: Parse Error: Non-function declaration:
    __BEGIN_DECLS : int. (For help on parse errors, see splint -help
    parseerrors.)
*** Cannot continue.

How to get past that?

bpv5P

  • Member
  • ***
  • Posts: 169
Re: Code static analysis and optimization tools
« Reply #6 on: August 11, 2017, 05:48:04 AM »
How to get past that?

Hi a1ex, I'll see if I can solve that.