Asterisk module dev

From 탱이의 잡동사니
Jump to navigation Jump to search

Ovreview

Asterisk module 만들어보기

Valgrind test

정확한 내용은 이곳<ref>https://wiki.asterisk.org/wiki/display/AST/Valgrind</ref>에서 확인할 수 있다.

Valgrind test 를 하기 위해서는 먼저 Asterisk 를 최적화 옵션을 끈채로 소스 컴파일을 하고, 이후 supp 파일과 함께 valgrind 를 실행하면 된다.

    Run 'make menuselect' and in the Compiler Options, enable DONT_OPTIMIZE. A bug marshal may also ask you to enable additional compiler flags depending upon the nature of the issue.
    Rebuild and install Asterisk.

    Run Asterisk as follows, where /usr/src/asterisk/ is location of asterisk source code.
    valgrind --suppressions=/usr/src/asterisk/contrib/valgrind.supp --log-fd=9 asterisk -vvvvcg 9>valgrind.txt
    Reproduce the issue. Following the manifestation of the issue (or when the process crashes), upload the valgrind.txt to the issue tracker.

최적화 옵션 On/Off 설정은 Compiler Flags 항목에 있다.

    --- Core ---
[*] DONT_OPTIMIZE
...

Core file

보통 Asterisk 를 컴파일을 하면 코어파일이 생기지 않는다.

코어파일이 남지 않으면 디버깅이 힘들어진다. 다음의 작업을 해주자.<ref>http://stackoverflow.com/questions/20743376/asterisk-gdb-how-to-debug-crash-with-gdb-and-asterisk-11-5-1-but-still-core-dunp</ref>

1) compile asterisk with debug symbols

2) in /etc/asterisk/asterisk.conf enable core dump.

더 자세한 디버깅 옵션을 확인하고 싶다면 이곳<ref>http://www.voip-info.org/wiki/view/Asterisk+debugging</ref>을 참조하자.

Backtracing

Backtracing a core dump file in /tmp

start Asterisk with safe_asterisk
enter "gdb asterisk core.xxxx"
enter "bt" while in gdb (or do a "bt full")
enter "thread apply all bt"

TEST_FRAMEWORK

Asterisk 에서 제공하는 TEST 소스 파일들을 컴파일하고 테스트하기 위해서는 TEST_FRAMEWORK 를 활성화 시켜야 한다. TEST_FRAMEWORK 를 활성화시키지 않으면 다음과 memuselect 에서 다음과 같은 메시지가 나온다.

XXX test_pbx
XXX test_poll
... More ...

ACL test module
Depends on: TEST_FRAMEWORK(E)

TEST_FRAMEWORK 활성화는 ./configure 실행시, --enable-dev-mode 옵션과 함께 실행하면 활성화 된다.

$ ./configure --enable-dev-mode

14.1.1

Asterisk 14.1.1 부터는 꽤나 많은 것들이 바꼈다.

AST_MODULE_SELF_SYM

14.1.1 부터는 AST_MODULE_SELF_SYM 을 define 해주어야 한다.

CFLAGS+=-DAST_MODULE=\"your_module_name\" -DAST_MODULE_SELF_SYM=__internal_your_module_name_self

ASTERISK_REGISTER_FILE

ASTERISK_FILE_VERSION(__FILE__, "$Revision$")

14.1.1 부터는 아래의 함수를 사용하거나 그냥 삭제 하도록 하자. 15부터는 사용하지 않는다고 한다.

(11:11:57 PM) coreyfarrell: pchero: I suggest just removing ASTERISK_FILE_VERSION / ASTERISK_REGISTER_FILE.  it no longer does anything and will not exist in Asterisk 15.
ASTERISK_REGISTER_FILE()

See also

References

<references />