Continued debugging
Co-authored-by: ValterMiari <ValterMiari@users.noreply.github.com>
This commit is contained in:
parent
5ac9b665a1
commit
42c22bc1eb
6 changed files with 95 additions and 57 deletions
|
|
@ -4,7 +4,8 @@ GC::Heap *gc = GC::Heap::the2();
|
|||
|
||||
void init() {
|
||||
std::vector<int> live_int_vec{1, 2, 3, 4, 5};
|
||||
std::vector<int> dead_int_vec(10, 1);
|
||||
std::vector<int> dead_int_vec(1000000, 1);
|
||||
int *arr = static_cast<int *>(gc->alloc(sizeof(int) * 300));
|
||||
int *a_ptr;
|
||||
int a = 10;
|
||||
a_ptr = &a;
|
||||
|
|
@ -16,7 +17,7 @@ void init() {
|
|||
|
||||
int main() {
|
||||
init();
|
||||
gc->force_collect();
|
||||
gc->collect(MARK | SWEEP);
|
||||
gc->print_contents();
|
||||
//delete gc;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -14,12 +14,18 @@ int main() {
|
|||
std::cout << "Start:\t\t" << prev1 << std::endl;
|
||||
#pragma clang diagnostic ignored "-Wframe-address"
|
||||
uintptr_t *tmp = reinterpret_cast<uintptr_t *>(__builtin_frame_address(1));
|
||||
std::cout << "Frame 1:\t" << tmp << "\t\tDiff:\t" << std::hex << "0x"<< prev1 - tmp << std::endl;
|
||||
std::cout << "Frame 1:\t" << tmp << "\t\tDiff:\t" << std::hex << "0x"<< tmp - prev1 << std::endl;
|
||||
prev1 = tmp;
|
||||
|
||||
#pragma clang diagnostic ignored "-Wframe-address"
|
||||
tmp = reinterpret_cast<uintptr_t *>(__builtin_frame_address(2));
|
||||
std::cout << "Frame 2:\t" << tmp << "\tDiff:\t" << std::hex << "0x" << prev1 - tmp << std::endl;
|
||||
std::cout << "Frame 2:\t" << tmp << "\tDiff:\t" << std::hex << "0x" << tmp - prev1 << std::endl;
|
||||
prev1 = tmp;
|
||||
|
||||
// arg > 2 for __builtin_frame_address() results in segfault
|
||||
// #pragma clang diagnostic ignored "-Wframe-address"
|
||||
// tmp = reinterpret_cast<uintptr_t *>(__builtin_frame_address(3));
|
||||
// std::cout << "Frame 3:\t" << tmp << "\tDiff:\t" << std::hex << "0x" << prev1 - tmp << std::endl;
|
||||
|
||||
dummy1();
|
||||
|
||||
|
|
@ -27,11 +33,11 @@ int main() {
|
|||
}
|
||||
|
||||
void dummy1() {
|
||||
std::cout << "Frame:\t\t" << __builtin_frame_address(0);
|
||||
std::cout << "D1 SFrame:\t" << __builtin_frame_address(0);
|
||||
#pragma clang diagnostic ignored "-Wframe-address"
|
||||
std::cout << "\t\tPrev:\t" << __builtin_frame_address(1) << std::endl;
|
||||
dummy2();
|
||||
std::cout << "D1 RA:\t\t" << std::hex << __builtin_return_address(0) << std::endl;
|
||||
dummy2();
|
||||
}
|
||||
|
||||
void dummy2() {
|
||||
|
|
@ -40,5 +46,6 @@ void dummy2() {
|
|||
std::cout << "\t\tPrev:\t" << __builtin_frame_address(1) << std::endl;
|
||||
void *ra = __builtin_return_address(0);
|
||||
std::cout << "D2 RA:\t\t" << std::hex << ra << std::endl;
|
||||
std::cout << "D2 ERA:\t\t" << std::hex << __builtin_extract_return_addr(ra) << std::endl;
|
||||
// gives same value as pure 'ra'
|
||||
// std::cout << "D2 ERA:\t\t" << std::hex << __builtin_extract_return_addr(ra) << std::endl;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue