-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
- Loading branch information
Showing
15 changed files
with
1,565 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM ubuntu:20.04 | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
ARG LIBABIGAIL_VERSION=1.8 | ||
RUN apt-get update && apt-get install -y build-essential \ | ||
libelf-dev \ | ||
libzip-dev \ | ||
autoconf \ | ||
libtool \ | ||
pkg-config \ | ||
libxml2 \ | ||
libxml2-dev \ | ||
elfutils \ | ||
doxygen \ | ||
wget \ | ||
git \ | ||
libdw-dev \ | ||
elfutils \ | ||
python3 \ | ||
python3-dev | ||
|
||
# Yes we are cheating with xmltodict :) | ||
RUN ldconfig && \ | ||
wget http://mirrors.kernel.org/sourceware/libabigail/libabigail-${LIBABIGAIL_VERSION}.tar.gz && \ | ||
tar -xvf libabigail-${LIBABIGAIL_VERSION}.tar.gz && \ | ||
cd libabigail-${LIBABIGAIL_VERSION} && \ | ||
mkdir build && \ | ||
cd build && \ | ||
../configure --prefix=/usr/local && \ | ||
make all install && \ | ||
ldconfig | ||
WORKDIR /code | ||
ADD . /code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Test Cases | ||
|
||
This is start of a folder where we can define (and run) test cases. A test case means: | ||
|
||
1. We've identified something we want to call an ABI conflict or incompatibility. | ||
2. We write a dummy example for it, in c and cpp (arguably we need more but let's start reasonably). | ||
3. We then compare results using abicompat, and whatever our method is, across a bunch of different compilers. | ||
|
||
To develop locally, I'll just use the small set of compilers that I have. But | ||
we will eventually move this to where there are more and we can test across them all. | ||
The test examples will not just allow us to compare output / results, but also | ||
let us run gdb to better understand what is going on (I haven't been able to do | ||
this yet). | ||
|
||
|
||
## Test Cases to Add | ||
|
||
This is a short list that I'm putting together from the work in [abi-python](../abi-python). | ||
|
||
0. **the environment has not changed**: This is an environment, as defined by libabigail. | ||
1. **A known needed symbol is undefined**: A symbol that is undefined in our main binary, and defined in the one that works, but not defined in the one we are comparing is a known needed symbol that is undefined. | ||
2. **The architecture do not match**: If the architectures do not match between the corpora, this is not compatible (we probably could compare either the libraries or the new library and the binary). | ||
3. **The sonames do not match**: if the sonames do not match (for either set) then they are not compatible. In practice my test library did not have one. | ||
4. **functions have the same length and order of parameters**: At least to start, we can say functions should have the same number of parameters, and if we compare the order, they are the same. In practice I don't know if this always has to hold true. We can call these parameters (in the same order of the same function) matching. | ||
5. **function matching parameters must have the same type and size**: Once we find a set of matching parameters, they need to have the same type and size. | ||
6. **parameters cannot be missing**: This is related to #4 because if a parameter is missing, the lengths would be different. But in practice, some of the compilers don't seem to be able to provide debug information for parameters, so they come across as missing. We need to be able to determine whether something is truly missing, or the compiler just decided to not include it. | ||
7. **arrays are the same if the elements are of the same type**: but this says nothing about their size. We will want a test case of different sizes to see what libabigail does. | ||
8. **references or pointers are the same if the thing they point to / the underlying types are the same** | ||
9. **enums are the same if we can match the entries 1:1 and they have the same type**: And we need to think about what happens if they have different lengths. | ||
10. **class types are the same if all of their base specifiers are the same** | ||
11. **class types are the same if all of their data members are the same** | ||
11. **class types are the same if all of their virtual member functions are the same** | ||
12. **class types are the same if all of their member function templates are the same** | ||
13. **union type declarations are the same if their non static data members are the same** | ||
14. **scopes are the same if their member declarations are the same** | ||
15. **Function declarations are the same if their types are the same** | ||
16. **Typedef declarations are the same if their underlying types are the same** | ||
17. **Translation units are the same if their global scopes are the same** | ||
|
||
## Getting Started | ||
|
||
First build the container, which has both libabigail and gdb. | ||
|
||
```bash | ||
$ docker build -t abigail . | ||
``` | ||
|
||
## gdb | ||
|
||
Here are instructions from Matt that I'll use for gdb, when the time comes. | ||
|
||
``` | ||
First: build libagigail with debug and no optimizations. | ||
On configure line: ‘CXXFLAGS=-O0 -g’ and ‘CFLAGS=-O0 -g’ | ||
Get test program | ||
Run abicompat in gdb: | ||
% gdb abicompat | ||
(gdb) break compute_diff #add breakpoint at compute_diff function | ||
(gdb) run [command line args to abicompat] | ||
… GDB tells you it hit a breakpoint at compute diff… | ||
(gdb) backtrace #print call stack | ||
(gdb) c #continue to next instance | ||
(gdb) p <some variable name> #print the value of a variable | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
all: | ||
gcc -g -fPIC -Wall -shared -o libmath-v1.so MathLibrary.c | ||
gcc -g -fPIC -Wall -shared -o libmath-v2.so MathLibraryChanged.c | ||
gcc -g -fPIC -Wall -o math-client MathClient.c -I . -L. libmath-v1.so | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// MathClient.cpp | ||
// compile with: cl /EHsc MathClient.cpp /link MathLibrary.lib | ||
|
||
#include <stdio.h> | ||
#include "MathLibrary.h" | ||
|
||
int main() | ||
{ | ||
double a = 7.4; | ||
int b = 99; | ||
|
||
printf("%f\n", Add(a, (double)b)); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// MathLibrary.cpp | ||
// compile with: cl /c /EHsc MathLibrary.cpp | ||
// post-build command: lib MathLibrary.obj | ||
|
||
#include "MathLibrary.h" | ||
|
||
double Add(double a, double b) | ||
{ | ||
return a + b; | ||
} | ||
|
||
double Subtract(double a, double b) | ||
{ | ||
return a - b; | ||
} | ||
|
||
double Multiply(double a, double b) | ||
{ | ||
return a * b; | ||
} | ||
|
||
double Divide(double a, double b) | ||
{ | ||
return a / b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// MathLibrary.h | ||
|
||
// Returns a + b | ||
double Add(double a, double b); | ||
|
||
// Returns a - b | ||
double Subtract(double a, double b); | ||
|
||
// Returns a * b | ||
double Multiply(double a, double b); | ||
|
||
// Returns a / b | ||
double Divide(double a, double b); |
25 changes: 25 additions & 0 deletions
25
test-cases/examples/parameter_type_change/c/MathLibraryChanged.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// MathLibrary.cpp | ||
// compile with: cl /c /EHsc MathLibrary.cpp | ||
// post-build command: lib MathLibrary.obj | ||
|
||
#include "MathLibraryChanged.h" | ||
|
||
int Add(int a, int b) | ||
{ | ||
return a + b; | ||
} | ||
|
||
double Subtract(double a, double b) | ||
{ | ||
return a - b; | ||
} | ||
|
||
double Multiply(double a, double b) | ||
{ | ||
return a * b; | ||
} | ||
|
||
double Divide(double a, double b) | ||
{ | ||
return a / b; | ||
} |
13 changes: 13 additions & 0 deletions
13
test-cases/examples/parameter_type_change/c/MathLibraryChanged.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// MathLibraryChanged.h | ||
|
||
// Returns a + b | ||
int Add(int a, int b); | ||
|
||
// Returns a - b | ||
double Subtract(double a, double b); | ||
|
||
// Returns a * b | ||
double Multiply(double a, double b); | ||
|
||
// Returns a / b | ||
double Divide(double a, double b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
all: | ||
g++ -g -Wall -fPIC -shared -o libmath-v1.so MathLibrary.cpp | ||
g++ -g -Wall -fPIC -shared -o libmath-v2.so MathLibraryChanged.cpp | ||
g++ -g -Wall -o math-client MathClient.cpp -I . -L. libmath-v1.so | ||
|
22 changes: 22 additions & 0 deletions
22
test-cases/examples/parameter_type_change/cpp/MathClient.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// MathClient.cpp | ||
// compile with: cl /EHsc MathClient.cpp /link MathLibrary.lib | ||
|
||
#include <iostream> | ||
#include "MathLibrary.h" | ||
|
||
int main() | ||
{ | ||
double a = 7.4; | ||
int b = 99; | ||
|
||
std::cout << "a + b = " << | ||
MathLibrary::Arithmetic::Add(a, b) << std::endl; | ||
std::cout << "a - b = " << | ||
MathLibrary::Arithmetic::Subtract(a, b) << std::endl; | ||
std::cout << "a * b = " << | ||
MathLibrary::Arithmetic::Multiply(a, b) << std::endl; | ||
std::cout << "a / b = " << | ||
MathLibrary::Arithmetic::Divide(a, b) << std::endl; | ||
|
||
return 0; | ||
} |
28 changes: 28 additions & 0 deletions
28
test-cases/examples/parameter_type_change/cpp/MathLibrary.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// MathLibrary.cpp | ||
// compile with: cl /c /EHsc MathLibrary.cpp | ||
// post-build command: lib MathLibrary.obj | ||
|
||
#include "MathLibrary.h" | ||
|
||
namespace MathLibrary | ||
{ | ||
double Arithmetic::Add(double a, double b) | ||
{ | ||
return a + b; | ||
} | ||
|
||
double Arithmetic::Subtract(double a, double b) | ||
{ | ||
return a - b; | ||
} | ||
|
||
double Arithmetic::Multiply(double a, double b) | ||
{ | ||
return a * b; | ||
} | ||
|
||
double Arithmetic::Divide(double a, double b) | ||
{ | ||
return a / b; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
test-cases/examples/parameter_type_change/cpp/MathLibrary.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// MathLibrary.h | ||
#pragma once | ||
|
||
namespace MathLibrary | ||
{ | ||
class Arithmetic | ||
{ | ||
public: | ||
// Returns a + b | ||
static double Add(double a, double b); | ||
|
||
// Returns a - b | ||
static double Subtract(double a, double b); | ||
|
||
// Returns a * b | ||
static double Multiply(double a, double b); | ||
|
||
// Returns a / b | ||
static double Divide(double a, double b); | ||
}; | ||
} |
28 changes: 28 additions & 0 deletions
28
test-cases/examples/parameter_type_change/cpp/MathLibraryChanged.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// MathLibrary.cpp | ||
// compile with: cl /c /EHsc MathLibrary.cpp | ||
// post-build command: lib MathLibrary.obj | ||
|
||
#include "MathLibraryChanged.hpp" | ||
|
||
namespace MathLibrary | ||
{ | ||
int Arithmetic::Add(int a, int b) | ||
{ | ||
return a + b; | ||
} | ||
|
||
double Arithmetic::Subtract(double a, double b) | ||
{ | ||
return a - b; | ||
} | ||
|
||
double Arithmetic::Multiply(double a, double b) | ||
{ | ||
return a * b; | ||
} | ||
|
||
double Arithmetic::Divide(double a, double b) | ||
{ | ||
return a / b; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
test-cases/examples/parameter_type_change/cpp/MathLibraryChanged.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// MathLibrary.h | ||
#pragma once | ||
|
||
namespace MathLibrary | ||
{ | ||
class Arithmetic | ||
{ | ||
public: | ||
// Returns a + b | ||
static int Add(int a, int b); | ||
|
||
// Returns a - b | ||
static double Subtract(double a, double b); | ||
|
||
// Returns a * b | ||
static double Multiply(double a, double b); | ||
|
||
// Returns a / b | ||
static double Divide(double a, double b); | ||
}; | ||
} |
Oops, something went wrong.