Tuesday, August 21, 2018

gdb 멀티쓰레드 디버깅

중단점이 걸렸다는 가정하에,

모든 thread 나열
gdb> info thread


해당 thread로 이동
gdb> thread [thread_number]



이하는 아직 이해 안됨. 정리중.






Tuesday, August 7, 2018

std::remove_if

#include <iostream>
#include <vector>
#include <algorithm>

int main(int argcv, char** argv)
{
    std::vector<int> test = {-1, 2, -3,-1,-5, 5,-5, -7,  -3, -3 , 6,  -1, 9 ,};
#if 1
    // success case
    auto f = [](int i) { return i < 0; };
    auto new_end =std::remove_if(test.begin(), test.end(), f);
    test.erase(new_end, test.end());
#else
    // failure case
    for(auto it = test.begin(); it != test.end(); it++){
        int i = *it;
        if(i < 0)
            test.erase(it);
    }
#endif
    for(auto it = test.begin(); it != test.end(); it++){
        int i = *it;
        printf("%d,", i);
    }
    printf("\n");
    return 0;
}


Monday, August 6, 2018

소스코드 부분 최적

https://twitter.com/MittringMartin/status/912817354827907073

Visual studio :
#pragma optimize( "", off )
 ..code..
#pragma optimize( "", on )


GCC 44.4 and up:
https://news.ycombinator.com/item?id=4711571

#pragma GCC push_options
#pragma GCC optimize ("O0")

memset(a, 0, 3); // .. code ..

#pragma GCC pop_options