public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug gdb/30242] New: gdb weird one specific command with specific input not valid to run
@ 2023-03-18  8:11 czgf2v at 163 dot com
  2023-03-18  8:18 ` [Bug gdb/30242] " czgf2v at 163 dot com
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: czgf2v at 163 dot com @ 2023-03-18  8:11 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=30242

            Bug ID: 30242
           Summary: gdb weird one specific command with specific input not
                    valid to run
           Product: gdb
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: czgf2v at 163 dot com
  Target Milestone: 14.1

Created attachment 14756
  --> https://sourceware.org/bugzilla/attachment.cgi?id=14756&action=edit
basic.c

my gdb config '~/dotfiles/colors.gdb'
```bash
set trace-commands on
shell test -e ~/.gdb-color-pipe && rm ~/.gdb-color-pipe
shell touch ~/.gdb-color-pipe && echo " " >> ~/.gdb-color-pipe && cat
~/.gdb-color-pipe && ls -al ~ | grep gdb
set confirm off
set logging overwrite on
set logging file ~/.gdb-color-pipe
# set logging redirect on

define hook-quit
    shell rm -f ~/.gdb-color-pipe
end

define setup-color-pipe
    set logging enabled on
end

define cleanup-color-pipe
    set logging enabled off 
end

document cleanup-color-pipe
    Disables command redirection and removes the color pipe file.
    Syntax: cleanup-color-pipe
end


define do-generic-colors
    # 1. Function names and the class they belong to
    # 2. Function argument names
    # 3. Stack frame number
    # 4. Thread id colorization
    # 5. File path and line number

    shell cat ~/.gdb-color-pipe | \
        sed -r "s_([^<])(\b([a-zA-Z0-9_]+::)?[a-zA-Z0-9_\.@]+)( ?)\(_\1$(tput
setaf 6)$(tput bold)\2$(tput sgr0)\4(_g" | \
        sed -r "s_([a-zA-Z0-9_#]*)=_$(tput setaf 2)$(tput bold)\1$(tput
sgr0)=_g" | \
        sed -r "s_^(#[0-9]*)_$(tput setaf 1)$(tput bold)\1$(tput sgr0)_" | \
        sed -r "s_^([ \*]) ([0-9]+)_$(tput bold)$(tput setaf 6)\1 $(tput setaf
1)\2$(tput sgr0)_" | \
        sed -r "s_(\.*[/A-Za-z0-9\+_\.\-]*):([0-9]+)\$_$(tput setaf 4)\1$(tput
sgr0):$(tput setaf 3)\2$(tput sgr0)_"
end

#------------------------------------------------------------------------------#
# Prompt
#------------------------------------------------------------------------------#


set prompt \001\033[01;34m\002(gdb) \001\033[0m\002


#------------------------------------------------------------------------------#
# backtrace
#------------------------------------------------------------------------------#

define hook-backtrace
    setup-color-pipe
end

define hookpost-backtrace
    do-generic-colors
    cleanup-color-pipe
end

#------------------------------------------------------------------------------#
# thread
#------------------------------------------------------------------------------#

define hook-thread
    setup-color-pipe
end

define hookpost-thread
    do-generic-colors
    cleanup-color-pipe
end
```
the following code lines with "+" is debug info.
I install gdb by
```bash
sudo add-apt-repository ppa:ubuntu-support-team/gdb
sudo apt update
sudo apt install gdb
# version in ubuntu =12.1.3139.g106791196f98+22.04.20221220200615
```
then I run
```bash
$ gdb -v
GNU gdb (GDB) 14.0.50.20221220-git
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ cd /home/czg/CSAPP-3e-Solutions/site/content/gdb_repl;gcc -gdwarf-5 -g3
-ggdb3 basic.c -o basic;gdb -q -nx -nh ./basic -ex 'source
~/dotfiles/colors.gdb' -ex "br 11" -ex "start"
+shell test -e ~/.gdb-color-pipe && rm ~/.gdb-color-pipe                        
+shell touch ~/.gdb-color-pipe && echo " " >> ~/.gdb-color-pipe && cat
~/.gdb-color-pipe && ls -al ~ | grep gdb                                   
drwxr-xr-x  2 czg  czg    4096 Mar 11 11:23 .cgdb                               
-rw-rw-r--  1 czg  czg       2 Mar 18 15:57 .gdb-color-pipe                     
-rw-------  1 czg  czg    3433 Mar 18 15:03 .gdb_history                        
-rw-rw-r--  1 czg  czg   93621 Mar 17 17:08 .gdbinit                            
-rw-rw-r--  1 czg  czg   57755 Mar 14 16:47 .gdbinit_basic                      
drwxrwxr-x  2 czg  czg    4096 Mar 14 17:33 .gdbinit.d                          
-rw-rw-r--  1 czg  czg   93621 Mar 16 14:47 .gdbinit_py                         
-rw-rw-r--  1 czg  czg   92481 Mar 11 12:56 gdb.py                              
-rw-rw-r--  1 czg  czg       0 Mar 16 18:09 .gdbtxt                             
drwxr-xr-x  2 czg  czg    4096 Mar 11 11:16 .tgdb
....
+br 11
Breakpoint 1 at 0x119e: file basic.c, line 11.
+start
Temporary breakpoint 2 at 0x117c: file basic.c, line 8.
Starting program: /home/czg/CSAPP-3e-Solutions/site/content/gdb_repl/basic 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Temporary breakpoint 2, main (argc=1, argv=0x7fffffffd6a8) at basic.c:8
8           int* basic = malloc(sizeof(int));
(gdb) bt
+bt
++setup-color-pipe
+++set logging enabled on
#0  main (argc=1, argv=0x7fffffffd6a8) at basic.c:8
++do-generic-colors
+++shell cat ~/.gdb-color-pipe |         sed -r
"s_([^<])(\b([a-zA-Z0-9_]+::)?[a-zA-Z0-9_\.@]+)( ?)\(_\1$(tput setaf 6)$(tput
bold)\2$(tput sgr0)\4(_g" |         sed -r "s_([a-zA-Z0-9_#]*)=_$(tput setaf
2)$(tput bold)\1$(tput sgr0)=_g" |         sed -r "s_^(#[0-9]*)_$(tput setaf
1)$(tput bold)\1$(tput sgr0)_" |         sed -r "s_^([ \*]) ([0-9]+)_$(tput
bold)$(tput setaf 6)\1 $(tput setaf 1)\2$(tput sgr0)_" |         sed -r
"s_(\.*[/A-Za-z0-9\+_\.\-]*):([0-9]+)\$_$(tput setaf 4)\1$(tput sgr0):$(tput
setaf 3)\2$(tput sgr0)_"
#0  main (argc=1, argv=0x7fffffffd6a8) at basic.c:8
++cleanup-color-pipe
+++set logging enabled off
(gdb) thread 
+thread 
++setup-color-pipe
+++set logging enabled on
[Current thread is 1 (Thread 0x7ffff7d58740 (LWP 48317))]
++do-generic-colors
+++shell cat ~/.gdb-color-pipe |         sed -r
"s_([^<])(\b([a-zA-Z0-9_]+::)?[a-zA-Z0-9_\.@]+)( ?)\(_\1$(tput setaf 6)$(tput
bold)\2$(tput sgr0)\4(_g" |         sed -r "s_([a-zA-Z0-9_#]*)=_$(tput setaf
2)$(tput bold)\1$(tput sgr0)=_g" |         sed -r "s_^(#[0-9]*)_$(tput setaf
1)$(tput bold)\1$(tput sgr0)_" |         sed -r "s_^([ \*]) ([0-9]+)_$(tput
bold)$(tput setaf 6)\1 $(tput setaf 1)\2$(tput sgr0)_" |         sed -r
"s_(\.*[/A-Za-z0-9\+_\.\-]*):([0-9]+)\$_$(tput setaf 4)\1$(tput sgr0):$(tput
setaf 3)\2$(tput sgr0)_"
++cleanup-color-pipe
+++set logging enabled off
(gdb) !echo $SHELL
+!echo $SHELL
/bin/bash
```
but if in outside shell with same command can output something which is weird.
```bash
$ echo $SHELL
/bin/bash
$ cat ~/.gdb-color-pipe |         sed -r
"s_([^<])(\b([a-zA-Z0-9_]+::)?[a-zA-Z0-9_\.@]+)( ?)\(_\1$(tput setaf 6)$(tput
bold)\2$(tput sgr0)\4(_g" |         sed -r "s_([a-zA-Z0-9_#]*)=_$(tput setaf
2)$(tput bold)\1$(tput sgr0)=_g" |         sed -r "s_^(#[0-9]*)_$(tput setaf
1)$(tput bold)\1$(tput sgr0)_" |         sed -r "s_^([ \*]) ([0-9]+)_$(tput
bold)$(tput setaf 6)\1 $(tput setaf 1)\2$(tput sgr0)_" |         sed -r
"s_(\.*[/A-Za-z0-9\+_\.\-]*):([0-9]+)\$_$(tput setaf 4)\1$(tput sgr0):$(tput
setaf 3)\2$(tput sgr0)_"
[Current thread is 1 (Thread 0x7ffff7d58740 (LWP 48317))]
++do-generic-colors
+++shell cat ~/.gdb-color-pipe |         sed -r
"s_([^<])(\b([a-zA-Z0-9_]+::)?[a-zA-Z0-9_\.@]+)( ?)\(_\1$(tput setaf 6)$(tput
bold)\2$(tput sgr0)\4(_g" |         sed -r "s_([a-zA-Z0-9_#]*)=_$(tput setaf
2)$(tput bold)\1$(tput sgr0)=_g" |         sed -r "s_^(#[0-9]*)_$(tput setaf
1)$(tput bold)\1$(tput sgr0)_" |         sed -r "s_^([ \*]) ([0-9]+)_$(tput
bold)$(tput setaf 6)\1 $(tput setaf 1)\2$(tput sgr0)_" |         sed -r
"s_(\.*[/A-Za-z0-9\+_\.\-]*):([0-9]+)\$_$(tput setaf 4)\1$(tput sgr0):$(tput
setaf 3)\2$(tput sgr0)_"
++cleanup-color-pipe
+++set logging enabled off
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-07-31 16:30 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-18  8:11 [Bug gdb/30242] New: gdb weird one specific command with specific input not valid to run czgf2v at 163 dot com
2023-03-18  8:18 ` [Bug gdb/30242] " czgf2v at 163 dot com
2023-03-18  8:18 ` czgf2v at 163 dot com
2023-03-18  8:19 ` czgf2v at 163 dot com
2023-03-18 15:11 ` tromey at sourceware dot org
2023-03-18 16:07 ` czgf2v at 163 dot com
2023-03-18 16:29 ` czgf2v at 163 dot com
2023-03-20 11:11 ` czgf2v at 163 dot com
2023-03-20 15:32 ` czgf2v at 163 dot com
2023-03-21 14:57 ` tromey at sourceware dot org
2023-03-22  8:11 ` czgf2v at 163 dot com
2023-07-05 14:22 ` brobecker at gnat dot com
2023-07-12  7:44 ` czgf2v at 163 dot com
2023-07-31 16:30 ` tromey at sourceware dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).