1- \page cpp-api-and-modularisation Libcprover -cpp and Modularisation
1+ \page cpp-api-and-modularisation libcprover -cpp and Modularisation
22
33** Date** : 22 Jun 2023
44** Updated** : 22 Jun 2023
55** Author** : Fotis Koutoulakis, fotis.koutoulakis@diffblue.com
66** Domain** : Architecture, API
77** Description** : This document outlines our thinking about the rearchitecting of
8- CBMC using the C++ API (` Libcprover -cpp` ) as the central module and the
8+ CBMC using the C++ API (` libcprover -cpp` ) as the central module and the
99 transitioning of other tools to use that as a basis.
1010
1111## Motivation && Current State of Affairs
1212
13- CProver is a collection of tools fitting various program analysis needs. It
13+ CProver is a collection of tools fitting various program analysis needs. CProver
1414has been the product of the evolution of the codebase of the model-checking
15- tool for C (` CBMC ` ), after it has been adopted with various front-ends/back-ends
16- and various auxilliary tools.
15+ tool for C (` CBMC ` ). Since then CProver has been adopted with various
16+ front-ends/back-ends and auxilliary tools.
1717
1818During this time, the repository has grown organically, using some guidelines
1919for development that were based on tradition and intuition rather than some
20- tight development guide . This development model has been successful for most
20+ agreed architectural approach . This development model has been successful for most
2121of CProver's life, based on its nature as a hybrid industrial/academic and
22- experimental/applied tool. However, it has had the side-effect of accruing
23- some code duplication and technical debt. It has also made the codebase harder
24- to understand/develop and integrate with, especially for someone who is new
25- to the codebase.
22+ experimental/applied tool. However, this has had the side-effect of accruing
23+ some code duplication and technical debt. Consequently, the codebase is complex
24+ and difficult to understand and develop for. This is a large barrier to new
25+ developers, new features, and also improving and fixing the existing CProver
26+ tools.
2627
2728The above concerns have generated discussions about the breaking down of
2829CProver into modules, with cleaner interfaces and tighter boundary control
2930between them, making the code easier to integrate in other projects (by making
3031the various component modules easier to combine and reuse) and making the
3132codebase easier to understand and maintain.
3233
34+ The desire to separate functionality into different functional units
35+ would also remove duplication and bloat, and prevent issues with the
36+ same flag behaving in different ways across CProver tools.
37+
3338## The Plan Going Forward
3439
3540Given the above outline, we have reached a point where we are strongly motivated
36- to take action to better componentise and modularise CProver.
37-
38- It's also an opportune time for us, given the existence of ` Libcprover-cpp `
41+ to take action to better componentise and modularise CProver. What we mean by
42+ "better componentise and modularise" is that right now, even though there
43+ exists some structure between different CBMC components (at the class level
44+ or at the code source file level), the different components aren't cleanly
45+ separated in terms of boundaries/concerns, which hinders their reusability
46+ or understandability.
47+
48+ It is also an opportune time for us, given the existence of ` libcprover-cpp `
3949the C++ API that we built to support interfacing with Rust (for now - other
4050languages may be coming in the future): we can use this as the basis of
4151development for an API exposing the interfaces of the various other modules
@@ -45,7 +55,7 @@ an incremental basis.
4555Of course, this is a project that is massive in scope, potentially being
4656exposed to further scope creep. We acknowledge that any effort to do what
4757we have discussed already is going to be a multi-year effort from our end,
48- and that we will need community alignment to achieve the outcome we're
58+ and that we will need community alignment to achieve the outcome we are
4959looking for.
5060
5161This is why we are looking into testing the approach on a smaller component
@@ -66,38 +76,44 @@ The aim of the PR was not only to allow for the tool with the narrower-scope
6676to come to life, but also to see if we could expose just enough of the
6777process to the C++ API and use that as the basis of the new tool.
6878
69- This whole process has been very informational : we found out that not only
79+ This whole process has been very informative : we found out that not only
7080we * can* use the C++ API in that capacity, but also that extending the API
7181as and when we need to, and doing the various refactorings to the other tools
7282on a Just-In-Time basis is viable.
7383
7484There have been, however, some limitations:
7585
7686* The C++ API is still nascent, and as such its support for various workflows
77- is just not present (at first ). We can (and do) build things fast, as and
78- when we need them - but it's nowhere near feature complete to provide for
87+ is just not present (yet ). We can (and do) build things fast, as and
88+ when we need them - but it is nowhere near feature complete to provide for
7989 all of a user's workflows at the time of this writing.
8090
91+ * Still on the C++ API, its usage as the implementation basis for the new
92+ tool ` goto-bmc ` means that the code-structure and patterns in ` goto-bmc `
93+ are going to differ from other existing tools in the CProver-suite.
94+
8195* CProver tools have primarily been based on textual output to report on the
8296 results of their function (be it analysis, or transformations, etc). This
83- hasn't been a problem up until this point (with the caveat that occassionally
97+ has not been a problem up until this point (with the caveat that occasionally
8498 requests for support of new textual formats come up and adding support for
8599 those has become a laborious process).
86100
87- There's a need however for the separation of concerns between the production
101+ There is a need however for the separation of concerns between the production
88102 of the results by the analysis engine and the presentation layer for those.
89103
90- We're working towards addressing these teething problems, but while we're
104+ We are working towards addressing these teething problems, but while we are
91105still operating on those, we have to accept some compromises in the architecture
92- of the code while we're iterating or stabilising several of the new or
106+ of the code while we are iterating or stabilising several of the new or
93107refactored parts.
94108
95109Be advised that some constructs may pop up in some limited locations
96- in the codebase that may appear questionable. We're only asking for
97- some patience while we're working out the best way to refactor them into
110+ in the codebase that may appear questionable. We are only asking for
111+ some patience while we are working out the best way to refactor them into
98112an architecture that is more cohesive with the long term vision for the
99113platform.
100114
101115From our end, we will do our best to avoid any spillover effects to
102116other areas of the codebase, and to avoid introducing any behavioural
103- regressions while we're implementing the above plan.
117+ regressions while we are implementing the above plan. Any constructs
118+ that may feature "questionable" changes to parts will be marked as such
119+ and be followed with an explanation as to why the decision was made.
0 commit comments