Creating a signal gdb can catch

64 views
Skip to first unread message

heid...@googlemail.com

unread,
May 31, 2023, 2:22:36 PM5/31/23
to DynamoRIO Users
Greetings, I want to create a signal or similar in dynamorio code that gdb can catch so I can do some callstack debugging. But no matter what I do, assert, raise ( SIGABRT) it always ends with the program exiting with no callstack.

Any idea what to do? 

Regards

sharma...@google.com

unread,
May 31, 2023, 5:17:37 PM5/31/23
to DynamoRIO Users
Hi,
Can you provide some more details? Like where in DynamoRIO code are you trying to generate the signal: is it in the code cache or somewhere else, how are you generating the signal? Are you sure that code is being run? As discussed on https://dynamorio.org/page_debugging.html, there can be issues while debugging DR with gdb.

Abhinav

heid...@googlemail.com

unread,
Jun 1, 2023, 5:47:12 AM6/1/23
to DynamoRIO Users
I want to create it inside the drtable_create function:

I have a problem on Aarch64 with drcov where two BB Table entries are created although I have no thread local caches enabled and drcov2lcov doesn't process the second one.

I created a ticket but it is unprocessed for weeks so I want to try looking into it myself. But first I have to understand what creates a new table and for that I need to set proper breakpoints for GDB.

Derek Bruening

unread,
Jun 1, 2023, 10:44:00 AM6/1/23
to heid...@googlemail.com, DynamoRIO Users
Here is one way to break on drtable_create: use `-msgbox_mask 15` in debug build to get a pause at each message including the one with all the symbol commands.  Then hit ^C and paste in those commands.  Then you can use regular gdb breakpoint commands.  (Remember to hit enter after continuing as it's waiting at the symbol message for enter.) (Below I also disable SIGBUS from safe-reads pausing gdb.)

derek@dynamorio:~/dr/build$ gdb --args bin64/drrun -msgbox_mask 15 -t drcov -- suite/tests/bin/simple_app

...

(gdb) r

Starting program: /home/derek/dr/build/bin64/drrun -msgbox_mask 15 -t drcov -- suite/tests/bin/simple_app

process 3239276 is executing new program: /home/derek/dr/build/lib64/debug/libdynamorio.so

<Starting application /home/derek/dr/build/suite/tests/bin/simple_app (3239276)>

<press enter to continue>


<Initial options = -no_dynamic_options -client_lib '/home/derek/dr/build/bin64/../clients/lib64/debug/libdrcov.so;0;' -client_lib64 '/home/derek/dr/build/bin64/../clients/lib64/debug/libdrcov.so;0;' -code_api -msgbox_mask 15 -stack_size 56K -signal_stack_size 32K -nop_initial_bblock -max_elide_jmp 0 -max_elide_call 0 -early_inject -emulate_brk -no_inline_ignored_syscalls -native_exec_default_list '' -no_native_exec_managed_code -no_indcall2direct >

<press enter to continue>


<Paste into GDB to debug DynamoRIO clients:

set confirm off

add-symbol-file '/home/derek/dr/build/bin64/../clients/lib64/debug/libdrcov.so' 0x0000ffffb3f8ba70

add-symbol-file '/home/derek/dr/build/lib64/debug/libdynamorio.so' 0x0000000071019430

add-symbol-file '/home/derek/dr/build/ext/lib64/debug/libdrcovlib.so' 0x0000ffffb3fc7f70

add-symbol-file '/home/derek/dr/build/ext/lib64/debug/libdrx.so' 0x0000ffffb3fe43b0

add-symbol-file '/home/derek/dr/build/ext/lib64/debug/libdrreg.so' 0x0000ffffb4000130

add-symbol-file '/home/derek/dr/build/ext/lib64/debug/libdrmgr.so' 0x0000ffffb401f470

>

<press enter to continue>

^C

Program received signal SIGINT, Interrupt.

0x000000007145e744 in ?? ()

(gdb) set confirm off

(gdb) add-symbol-file '/home/derek/dr/build/bin64/../clients/lib64/debug/libdrcov.so' 0x0000ffffb3f8ba70

add symbol table from file "/home/derek/dr/build/bin64/../clients/lib64/debug/libdrcov.so" at

.text_addr = 0xffffb3f8ba70

Reading symbols from /home/derek/dr/build/bin64/../clients/lib64/debug/libdrcov.so...

Reading symbols from /home/derek/dr/build/clients/lib64/debug/libdrcov.so.debug...

(gdb) add-symbol-file '/home/derek/dr/build/lib64/debug/libdynamorio.so' 0x0000000071019430

add symbol table from file "/home/derek/dr/build/lib64/debug/libdynamorio.so" at

.text_addr = 0x71019430

Reading symbols from /home/derek/dr/build/lib64/debug/libdynamorio.so...

Reading symbols from /home/derek/dr/build/lib64/debug/libdynamorio.so.debug...

(gdb) add-symbol-file '/home/derek/dr/build/ext/lib64/debug/libdrcovlib.so' 0x0000ffffb3fc7f70

add symbol table from file "/home/derek/dr/build/ext/lib64/debug/libdrcovlib.so" at

.text_addr = 0xffffb3fc7f70

Reading symbols from /home/derek/dr/build/ext/lib64/debug/libdrcovlib.so...

Reading symbols from /home/derek/dr/build/ext/lib64/debug/libdrcovlib.so.debug...

(gdb) add-symbol-file '/home/derek/dr/build/ext/lib64/debug/libdrx.so' 0x0000ffffb3fe43b0

add symbol table from file "/home/derek/dr/build/ext/lib64/debug/libdrx.so" at

.text_addr = 0xffffb3fe43b0

Reading symbols from /home/derek/dr/build/ext/lib64/debug/libdrx.so...

Reading symbols from /home/derek/dr/build/ext/lib64/debug/libdrx.so.debug...

(gdb) add-symbol-file '/home/derek/dr/build/ext/lib64/debug/libdrreg.so' 0x0000ffffb4000130

add symbol table from file "/home/derek/dr/build/ext/lib64/debug/libdrreg.so" at

.text_addr = 0xffffb4000130

Reading symbols from /home/derek/dr/build/ext/lib64/debug/libdrreg.so...

Reading symbols from /home/derek/dr/build/ext/lib64/debug/libdrreg.so.debug...

(gdb) add-symbol-file '/home/derek/dr/build/ext/lib64/debug/libdrmgr.so' 0x0000ffffb401f470

add symbol table from file "/home/derek/dr/build/ext/lib64/debug/libdrmgr.so" at

.text_addr = 0xffffb401f470

Reading symbols from /home/derek/dr/build/ext/lib64/debug/libdrmgr.so...

Reading symbols from /home/derek/dr/build/ext/lib64/debug/libdrmgr.so.debug...

(gdb) b drtable_create

Breakpoint 1 at 0xffffb3fcc408: file /home/derek/dr/src/ext/drcontainers/drtable.c, line 171.

(gdb) handle SIGBUS nostop noprint pass

Signal        Stop Print Pass to program Description

SIGBUS        No No Yes Bus error

(gdb) c

Continuing.



Breakpoint 1, drtable_create (capacity=4096, entry_size=8, flags=0, synch=1 '\001', free_entry_func=0x0) at /home/derek/dr/src/ext/drcontainers/drtable.c:171

171     DR_ASSERT(entry_size > 0 && entry_size < MAX_ENTRY_SIZE);

(gdb) bt

#0  drtable_create (capacity=4096, entry_size=8, flags=0, synch=1 '\001', free_entry_func=0x0) at /home/derek/dr/src/ext/drcontainers/drtable.c:171

#1  0x0000ffffb3fc84ac in bb_table_create (synch=1 '\001') at /home/derek/dr/src/ext/drcovlib/drcovlib.c:188

#2  0x0000ffffb3fc8778 in thread_data_create (drcontext=0x0) at /home/derek/dr/src/ext/drcovlib/drcovlib.c:258

#3  0x0000ffffb3fc88b0 in global_data_create () at /home/derek/dr/src/ext/drcovlib/drcovlib.c:282

#4  0x0000ffffb3fc930c in event_init () at /home/derek/dr/src/ext/drcovlib/drcovlib.c:543

#5  0x0000ffffb3fc953c in drcovlib_init (ops=0xffffffffdec8) at /home/derek/dr/src/ext/drcovlib/drcovlib.c:599

#6  0x0000ffffb3f8c0fc in dr_client_main (id=0, argc=1, argv=0xfffdb3fcda28) at /home/derek/dr/src/clients/drcov/drcov.c:179

#7  0x00000000711e1f5c in instrument_init () at /home/derek/dr/src/core/lib/instrument.c:772

#8  0x000000007102facc in dynamorio_app_init_part_two_finalize () at /home/derek/dr/src/core/dynamo.c:716

#9  0x000000007144c490 in privload_early_inject (sp=0xfffffffff420, old_libdr_base=0xfffff7a64000 <error: Cannot access memory at address 0xfffff7a64000>, 

    old_libdr_size=5881856) at /home/derek/dr/src/core/unix/loader.c:2254 

--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dynamorio-users/a8490d9a-d00f-4114-a007-518cc51a7aebn%40googlegroups.com.

heid...@googlemail.com

unread,
Jun 5, 2023, 10:11:53 AM6/5/23
to DynamoRIO Users
Hmm I add the symbol files before running drcov then set the breakpoint at drtable_create. But it never stops there.

Derek Bruening

unread,
Jun 5, 2023, 11:47:43 AM6/5/23
to heid...@googlemail.com, DynamoRIO Users
It's not easy to help without details: please provide the whole gdb transcript.  What does "before running drcov" mean?  Before the execve?  That is too early and will not work.  What was the output from the gdb commands?  Paste in everything, please.

heid...@googlemail.com

unread,
Jun 5, 2023, 3:43:21 PM6/5/23
to DynamoRIO Users
Yeah I made the mistake of not using the add symbols from the same run. Now I can break, must see if this will work on arm.

Need to find out where that second table comes from.

heid...@googlemail.com

unread,
Jun 5, 2023, 4:36:08 PM6/5/23
to DynamoRIO Users
Ok, it manages to set the breakpoint but crashes on first hit:

#0  drtable_create (capacity=4096, entry_size=8, flags=0, synch=1 '\001', free_entry_func=0x0) at /home/runner/work/dynamorio/dynamorio/ext/drcontainers/drtable.c:171
#1  0x00000000738024ac in bb_table_create (synch=1 '\001') at /home/runner/work/dynamorio/dynamorio/ext/drcovlib/drcovlib.c:188
#2  0x0000000073802778 in thread_data_create (drcontext=0x0) at /home/runner/work/dynamorio/dynamorio/ext/drcovlib/drcovlib.c:258
#3  0x00000000738028b0 in global_data_create () at /home/runner/work/dynamorio/dynamorio/ext/drcovlib/drcovlib.c:282
#4  0x000000007380330c in event_init () at /home/runner/work/dynamorio/dynamorio/ext/drcovlib/drcovlib.c:543
#5  0x000000007380353c in drcovlib_init (ops=0x7fffffe528) at /home/runner/work/dynamorio/dynamorio/ext/drcovlib/drcovlib.c:599
#6  0x0000000072000c10 in dr_client_main (id=0, argc=2, argv=0x7df7fe7048) at /home/runner/work/dynamorio/dynamorio/clients/drcov/drcov.c:179
#7  0x00000000711deb28 in instrument_init () at /home/runner/work/dynamorio/dynamorio/core/lib/instrument.c:772
#8  0x000000007102f6c4 in dynamorio_app_init_part_two_finalize () at /home/runner/work/dynamorio/dynamorio/core/dynamo.c:716
#9  0x0000000071442638 in privload_early_inject (sp=0x7ffffffa80, old_libdr_base=0x7ff7a6e000 "", old_libdr_size=5840896) at /home/runner/work/dynamorio/dynamorio/core/unix/loader.c:2254
#10 0x0000000071402fb4 in _start () at /home/runner/work/dynamorio/dynamorio/core/arch/aarchxx/aarchxx.asm:68


Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) c
Continuing.
<Application /usr/bin/myapp (5135).  DrCov internal crash at PC 0x0000000073806408.  Please report this at http://dynamorio.org/issues.  Program aborted.
Received SIGSEGV at pc 0x0000000073806408 in thread 5135
Base: 0x0000000071000000
Registers:      eflags=0x0000000060201000
version 9.91.19440, custom build
-no_dynamic_options -client_lib '/var/DynamoRIO-AArch64-Linux-9.91.19440/bin64/../tools/lib64/release/libdrcov.so;0;"-dump_binary"' -client_lib64 '/var/DynamoRIO-AArch64-Linux-9.91.19440/bin64/../tools/lib64/release/libdrcov.so;0;"-dump_binary"' -code_api -msgbox_mask 15 -stack_size 56K -signal_stack_size 32K -nop_initia
0x0000007fffffe3a0 0x00000000738024ac
0x0000007fffffe3f0 0x0000000073802778
0x0000007fffffe410 0x00000000738028b0
0x0000007fffffe440 0x000000007380330c
0x0000007fffffe450 0x000000007380353c
0x0000007fffffe480 0x0000000072000c10
0x0000007fffffe4b0 0x00000000711deb28
0x0000007fffffe550 0x000000007102f6c4
0x0000007fffffe590 0x0000000071442638
0x0000007fffffedc0 0x0000000071402fb4>
<press enter to continue>

[Inferior 1 (process 5135) exited with code 0377]

I also never reach the second call to drtable_create because an internal watchdog shuts down the program as -debug makes it too slow.
Is there another way to generate the add-symbols message in release? x/3s gdb_priv_cmds doesn't show this.

Regards
Reply all
Reply to author
Forward
0 new messages