-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51f5a15
commit ed9f406
Showing
6 changed files
with
73 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,15 @@ | ||
#include "fuga.h" | ||
|
||
struct CustomException {}; | ||
|
||
void throw_exception_fuga() { | ||
throw CustomException(); | ||
} | ||
|
||
void catch_exception_fuga() { | ||
try { | ||
throw_exception_fuga(); | ||
} catch (CustomException) { | ||
std::cerr << "Caught CustomException" << std::endl; | ||
} | ||
} |
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,6 @@ | ||
#include <exception> | ||
#include <iostream> | ||
#include <stdexcept> | ||
|
||
void throw_exception_fuga(); | ||
void catch_exception_fuga(); |
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,20 @@ | ||
#include "hoge.h" | ||
#include "fuga.h" | ||
|
||
void throw_exception_hoge() { | ||
throw std::runtime_error("hoge from throw_exception_hoge"); | ||
} | ||
|
||
void catch_exception_hoge() { | ||
try { | ||
throw_exception_hoge(); | ||
} catch (std::exception& e) { | ||
std::cout << e.what() << std::endl; | ||
} | ||
|
||
try { | ||
throw_exception_fuga(); | ||
} catch (std::exception& e) { | ||
std::cout << e.what() << std::endl; | ||
} | ||
} |
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,6 @@ | ||
#include <exception> | ||
#include <iostream> | ||
#include <stdexcept> | ||
|
||
void throw_exception_hoge(); | ||
void catch_exception_hoge(); |
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 @@ | ||
#include "hoge.h" | ||
|
||
int main() { | ||
std::cout << "catch_exception" << std::endl; | ||
catch_exception_hoge(); | ||
|
||
std::cout << "throw_exception" << std::endl; | ||
try { | ||
throw_exception_hoge(); | ||
} catch (std::exception& e) { | ||
std::cout << e.what() << std::endl; | ||
} | ||
} |
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 @@ | ||
#! /bin/bash -eu | ||
|
||
g++ -fPIC -shared -o libfuga.so -Wl,-soname,libfuga.so fuga.cc | ||
g++ -fPIC -shared -o libhoge.so.original -Wl,-soname,libhoge.so hoge.cc libfuga.so | ||
g++ main.cc -o main.out libhoge.so.original libfuga.so | ||
LD_LIBRARY_PATH=. $(git rev-parse --show-toplevel)/build/sold -i libhoge.so.original -o libhoge.so.soldout --section-headers --check-output | ||
|
||
# Use sold | ||
ln -sf libhoge.so.soldout libhoge.so | ||
# Use original | ||
ln -sf libhoge.so.original libhoge.so | ||
|
||
LD_LIBRARY_PATH=. ./main.out |