mangle

demangle

gcc compile

1
2
# void test(int i)
c++filt -n <_Z4testi>

self configuration in linux

install

1
2
3
apt install build-essential

echo $PATH

bachrc

1
2
3
4
5
6
7
8
# git
alias mgs="git status"
alias mgc="git commit"
alias mgca="git commit --amend"

# cmake
alias mcmakec="rm -rf build && cmake -S . -B build"
alias mcmakeb="cmake --build build --parallel 32 "
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# generate ssh key pair
ssh-keygen -t ed25519 -C helianthus547@gmail.com

# login without password
ssh-copy-id -i ~/.ssh/id_ed25519.pub heli@192.168.1.113

# login without server information alias
vim ~/.ssh/config

Host WS
HostName 192.168.1.113
Port 22
User heli
IdentityFile ~/.ssh/id_ed25519

# verify git can ssh use
ssh -T git@github.com

change to nerd font

1
2
3
4
5
6
7
8
9
10
11
12
13
14
apt install -yqq fontconfig

wget -q -nv https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/JetBrainsMono.zip

unzip JetBrainsMono.zip -d ~/.local/share/fonts

fc-cache -fv

# macbook
brew search font
brew install font-jetbrains-mono-nerd-font

# vscode
'JetbrainsMonoNL Nerd Font Mono'

tar

1
2
3
4
5
6
7
# zip
## -c create
tar -zcvf xxx.tar.gz source_file

# unzip
## -x extract
tar -zxvf xxx.tar.gz -C path

big or little endian

lscpu

1
2
3
4
5
6
7
8
9
10
11
12
#include <bit>
#include <iostream>

int main()
{
if constexpr (std::endian::native == std::endian::big)
std::cout << "big-endian\n";
else if constexpr (std::endian::native == std::endian::little)
std::cout << "little-endian\n";
else
std::cout << "mixed-endian\n";
}
1
2
3
4
5
6
7
8
9
10
11
12
union T {
int i;
char byte[];
} t;

int main()
{
t.i = 1;
t.byte[0] == 1;

return
}

binutils usage

install

Ubuntu

1
apt install binutils

objdump

inspect full assembly

1
objdump -D <.o> |less

readelf

pmr

C++ 17 引入了内存相关的一系列可重写的 API。 在头文件 memory_resource 中。命名空间在 std::pmr:: ,目的在于

  1. 池化内存分配,减少频繁系统调用分配或释放内存,带来的性能损失
  2. 与已有 std 中的 allocator, container 结合,方便使用者自定义相关的内存分配策略类
  3. 特殊的使用场景:内存分配效率敏感、需要禁用内存分配。如因功能安全需要,自动驾驶代码禁止动态内存分配
Read more

gdb-cpp

gdb 调试 cpp 数据结构的特殊情形

  • std::string
  • std::vector
Read more

tmux

tmux cheatsheet

Read more