Fork from http://sourceforge.net/projects/state-threads, patched for SRS.
See: https://github.com/ossrs/state-threads/blob/srs/README
For original ST without any changes, checkout the ST master branch.
state-threads is licenced under MPL or GPLv2.
Get code:
git clone -b srs https://github.com/ossrs/state-threads.gitFor Linux:
make linux-debugFor Linux aarch64, which fail with Unknown CPU architecture:
make linux-debug EXTRA_CFLAGS="-D__aarch64__"Note: For more CPU architectures, please see #22
Linux with valgrind:
make linux-debug EXTRA_CFLAGS="-DMD_VALGRIND"Remark: User must install valgrind, for instance, in centos6
sudo yum install -y valgrind valgrind-devel.
Linux with valgrind and epoll:
make linux-debug EXTRA_CFLAGS="-DMD_HAVE_EPOLL -DMD_VALGRIND"Get code:
git clone -b srs https://github.com/ossrs/state-threads.gitFor OSX:
make darwin-debugFor OSX, user must specifies the valgrind header files:
make darwin-debug EXTRA_CFLAGS="-DMD_HAVE_KQUEUE -DMD_VALGRIND -I/usr/local/include"Remark: M1 is unsupported by ST, please use docker to run, please read SRS#2747.
Get code:
git clone -b srs https://github.com/ossrs/state-threads.gitFor Cygwin(Windows):
make cygwin64-debug
Remark: Windows native build is unsupported right now.
The branch srs was patched and refined:
MD_ST_NO_ASM to disable ASM, #8.How to debug with gdb under valgrind, read valgrind manual.
About startup parameters, read valgrind cli.
Important cli options:
--undef-value-errors=<yes|no> [default: yes], Controls whether Memcheck reports uses of undefined value errors. Set this to no if you don't want to see undefined value errors. It also has the side effect of speeding up Memcheck somewhat.--leak-check=<no|summary|yes|full> [default: summary], When enabled, search for memory leaks when the client program finishes. If set to summary, it says how many leaks occurred. If set to full or yes, each individual leak will be shown in detail and/or counted as an error, as specified by the options --show-leak-kinds and --errors-for-leak-kinds.--track-origins=<yes|no> [default: no], Controls whether Memcheck tracks the origin of uninitialised values. By default, it does not, which means that although it can tell you that an uninitialised value is being used in a dangerous way, it cannot tell you where the uninitialised value came from. This often makes it difficult to track down the root problem.--show-reachable=<yes|no> , --show-possibly-lost=<yes|no>, to show the using memory.Note: We use Google test in
utest/gtest-fit.
To make ST with utest and run it:
make linux-debug-utest && ./obj/st_utestNote that the gcc(4.8) of CentOS is too old, please use docker(ossrs/srs:dev-gcc7) to run:
docker run --rm -it -v $(pwd):/state-threads -w /state-threads
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:dev-gcc7
bash -c 'make linux-debug-utest && ./obj/st_utest'Note: We use Google test in
utest/gtest-fit.
To make ST with utest and run it:
make darwin-debug-utest && ./obj/st_utestNote: We use Google test in
utest/gtest-fit.
To make ST with utest and run it:
make linux-debug-gcov && ./obj/st_utestNote that the gcc(4.8) of CentOS is too old, please use docker(ossrs/srs:dev-gcc7) to run:
docker run --rm -it -v $(pwd):/state-threads -w /state-threads
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:dev-gcc7
bash -c 'make linux-debug-gcov && ./obj/st_utest'Then, install gcovr for coverage:
yum install -y python2-pip &&
pip install lxml && pip install gcovrFinally, run test and get the report:
bash auto/coverage.shNote: We use Google test in
utest/gtest-fit.
To make ST with utest and run it:
make darwin-debug-gcov && ./obj/st_utestThen, install gcovr for coverage:
pip install gcovrFinally, run test and get the report:
bash auto/coverage.shIntroduction: http://ossrs.github.io/state-threads/docs/st.html
API reference: http://ossrs.github.io/state-threads/docs/reference.html
Programming notes: http://ossrs.github.io/state-threads/docs/notes.html
How to porting ST to other OS/CPU?
About setjmp and longjmp, read setjmp.
About the stack structure, read stack
About asm code comments, read #91d530e.
About the scheduler, read #13-scheduler.
About the IO event system, read #13-IO.
Code analysis, please read #15.
Use CLion to open directory state-threads.
Then, open ide/st_clion/CMakeLists.txt and click Load CMake project.
Finally, select a configuration to run or debug.
Winlin 2016