Skip to content

Add symtab2gb to enable linking of .json_symtab files #4645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ set_target_properties(
linking
pointer-analysis
solvers
symtab2gb
testing-utils
unit
util
Expand Down
1 change: 1 addition & 0 deletions regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ add_subdirectory(contracts)
add_subdirectory(goto-harness)
add_subdirectory(goto-cc-file-local)
add_subdirectory(linking-goto-binaries)
add_subdirectory(symtab2gb)
1 change: 1 addition & 0 deletions regression/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ DIRS = cbmc \
contracts \
goto-cc-file-local \
linking-goto-binaries \
symtab2gb \
# Empty last line

# Run all test directories in sequence
Expand Down
3 changes: 3 additions & 0 deletions regression/symtab2gb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_test_pl_tests(
"${CMAKE_CURRENT_SOURCE_DIR}/chain.sh $<TARGET_FILE:symtab2gb> $<TARGET_FILE:cbmc>"
)
27 changes: 27 additions & 0 deletions regression/symtab2gb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
default: tests.log

include ../../src/config.inc
include ../../src/common

test:
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/symtab2gb/symtab2gb ../../../src/cbmc/cbmc'

tests.log:
@../test.pl -e -p -c '../chain.sh $(exe) ../../../src/symtab2gb/symtab2gb ../../../src/cbmc/cbmc'

show:
@for dir in *; do \
if [ -d "$$dir" ]; then \
vim -o "$$dir/*.c" "$$dir/*.out"; \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$VISUAL or $EDITOR, rather than "vim" ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -o option is specific to vim, and it's the same bit of code we have everywhere else. But I don't know whether anyone ever users this target?!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this was the first time I've actually noticed this target - never used it myself!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto on never using it. It's honestly a bit of cargo culting, I was kind of assuming someone around here liked to work that way. But I certainly don't mind removing it, I have no attachment to it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd vote for having a separate PR that removes all of those. If someone is still using them, we can then have that discussion on the PR.

fi; \
done;

clean:
@for dir in *; do \
$(RM) tests.log; \
if [ -d "$$dir" ]; then \
cd "$$dir"; \
$(RM) *.out *.gb; \
cd ..; \
fi \
done
6 changes: 6 additions & 0 deletions regression/symtab2gb/chain.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
symtab2gb_exe=$1
cbmc_exe=$2

$symtab2gb_exe "${@:3}"
$cbmc_exe a.out
19 changes: 19 additions & 0 deletions regression/symtab2gb/multiple_symtabs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
The `*.json_symtab` in this directory was created from the Ada source
files `*.adb` using the
[gnat2goto](https://github.com/diffblue/gnat2goto) compiler.

```
gnat2goto user.adb # produces user.json_symtab

# produces library.json_symtab
# and user.json_symtab
# the --no-cprover-start option is to prevent
# emitting a __CPROVER_start function for these modules,
# as there can only be one of those in a program

gnat2goto --no-cprover-start library.adb
gnat2goto --no-cprover-start user.adb
```

Note that as of now, this requires the patch found in
[this PR](https://github.com/diffblue/gnat2goto/pull/212)
7 changes: 7 additions & 0 deletions regression/symtab2gb/multiple_symtabs/entry_point.adb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
with User;
with Library;
procedure Entry_Point is
begin
User;
Library (-5);
end Entry_Point;
Loading