How to runtime debug shared libraries?

后端 未结 6 1639
时光说笑
时光说笑 2020-12-07 16:52

Can anyone tell me how to do runtime debugging on shared libraries?

I need to runtime-debug a function in my shared library, but its called by another program. How c

6条回答
  •  一生所求
    2020-12-07 17:14

    Another example further to lothar's answer:

    I'm running tests on a dynamic library test.so (compiled from test.c) in Linux using python and python's unit-testing library unittest called tests/test_pwmbasic.py. (naming scheme is a bit monotone, I realise that now)

    ~/my/test/path/
        tests/
            __init__.py
            test_pwmbasic.py
        test.c
        test.so
    

    I want to debug what's in test.so from stimulus in test_pwmbasic.py. So this is how I got it working...

    $ cd ~/my/test/path
    $ gdb $(which python)
       ... gdb blah ...
    (gdb) b test.c:179
    (gdb) run
    >>> from tests.test_pwmbasic import *
    >>> import unittest
    >>> unittest.main()
       ... unittest blah ...
    Breakpoint 1, pwmTest_setDutyCycles (dutyCycles=0x7ffff7ece910) at ./test.c:179
    (gdb) print pwm_errorCode
    $1 = PWM_ERROR_NONE
    

    and now I want to marry gdb

    note: test.c also includes ../pwm.c, so I can also breakpoint within that library with

    (gdb) b pwm.c:123
    

提交回复
热议问题