palves / misc

Misc helper development scripts
5 stars 1 forks source link

signals.gdb seems to be broken #1

Open agvxov opened 1 year ago

agvxov commented 1 year ago

On invocation it yields:

Number  Name            Description                     Disposition
A syntax error in expression, near ``off_t)) mmap'.

Reproduces with an otherwise empty .gdbinit file too.

$ gdb -v
GNU gdb (Gentoo 13.1.90_p20230325 vanilla) 13.1.90.20230325-git

Otherwise the script looks lovely, hope this gets resolved.

EDIT: i fixed the formatting, sorry

rvansa commented 1 year ago

In my case it doesn't show much and complains about unknown symbols:

(gdb) info signal-dispositions 
Number  Name        Description                 Disposition
1   SIGHUP      No symbol "_new_sys_siglist" in current context.
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
palves commented 1 year ago

@agvxov sorry, I completely missed this comment until today. Not exactly sure what is that, I'll see if I can spot something when I have a chance.

@rvansa I've noticed that just a couple days ago -- glibc changed, and that symbol no longer exists. The change below fixes it. I hadn't pushed it because I'd like to make it handle both new and old systems gracefully.

diff --git i/gdb/signals.gdb w/gdb/signals.gdb
index 09fd62b..49e1228 100644
--- i/gdb/signals.gdb
+++ w/gdb/signals.gdb
@@ -182,8 +182,8 @@ define __isd_print_disposition
       printf "SIG%d    ", $_isd_sig
     end
     printf "\t"
-    if _new_sys_siglist[$arg0] != 0
-      printf "%-24s", _new_sys_siglist[$arg0]
+    if __sys_siglist[$arg0] != 0
+      printf "%-24s", __sys_siglist[$arg0]
     else
       if $arg0 >= 34
        printf "Real-time signal %d", $arg0 - 34
rvansa commented 1 year ago

Awesome, thanks for such a quick fix! I confirm that this works now, as long as the signal is not raised. When I've tried to use it in a multi-threaded app that keeps receiving SIGTTOU, I get this:

The program received a signal in another thread while
making a function call from GDB.
Evaluation of the expression containing the function
(__GI___libc_malloc) will be abandoned.
When the function is done executing, GDB will silently stop.

I guess that this is just a limitation of the way GDB evaluates this. Not sure if forcibly blocking signals for the duration of invocation would help.

agvxov commented 1 year ago

@palves no worries, im just glad there is maintenance at all. the update did fix gdb complaining about the syntax (which is cryptic).

Now its a question of:

$ info signal-dispositions
Number  Name            Description                     Disposition
No struct type named sigaction.