Solved

gdb script not working with -k and -wcore and -x options in new version of gdb, Is there an alternate meathod to count the number of file descriptors in use?

Posted on 2010-11-24
1
1,068 Views
Last Modified: 2013-11-22
This works in IPSO 4.2:
#!/bin/sh

FILE=/tmp/patch.$$
cat << _EOF > $FILE
x/1d (&nfiles)
quit
_EOF
NUMFD=`gdb -k -wcore -batch -x $FILE /image/current/kernel /dev/mem \ | grep nfiles | awk ' { print $3 } '`

echo "There are $NUMFD file descriptors in use"
rm $FILE

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
In IPSO 6.2 I get:
# ./numdescriptors.sh
gdb: unrecognized option `-k'
Use `gdb --help' for a complete list of options.
There are  file descriptors in use


>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Options for IPSO 6.2:
# gdb --help
This is the GNU debugger.  Usage:

    gdb [options] [executable-file [core-file or process-id]]
    gdb [options] --args executable-file [inferior-arguments ...]


  --args             Arguments after executable-file are passed to inferior
  --[no]async        Enable (disable) asynchronous version of CLI
  -b BAUDRATE        Set serial port baud rate used for remote debugging.
  --batch            Exit after processing options.
  --cd=DIR           Change current directory to DIR.
  --command=FILE     Execute GDB commands from FILE.
  --core=COREFILE    Analyze the core dump COREFILE.
  --pid=PID          Attach to running process PID.
  --dbx              DBX compatibility mode.
  --directory=DIR    Search for source files in DIR.
  --epoch            Output information used by epoch emacs-GDB interface.
  --exec=EXECFILE    Use EXECFILE as the executable.
  --fullname         Output information used by emacs-GDB interface.
  --help             Print this message.
  --interpreter=INTERP
                     Select a specific interpreter / user interface
  --mapped           Use mapped symbol files if supported on this system.
  --nw               Do not use a window interface.
  --nx               Do not read .gdbinit file.
  --quiet            Do not print version number on startup.
  --readnow          Fully read symbol files on first access.
  --se=FILE          Use FILE as symbol file and executable file.
  --symbols=SYMFILE  Read symbols from SYMFILE.
  --tty=TTY          Use TTY for input/output by the program being debugged.
  --tui              Use a terminal user interface.
  --version          Print version information and then exit.
  -w                 Use a window interface.
  --write            Set writing into executable and core files.
  --xdb              XDB compatibility mode.

For more information, type "help" from within GDB, or consult the
GDB manual (available as on-line info or a printed manual).
Report bugs to "bug-gdb@gnu.org".

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Options for IPSO 4.1:
# gdb --help
GDB 4.16 (i386-unknown-freebsd), Copyright 1996 Free Software Foundation, Inc.
This is the GNU debugger.  Usage:
    gdb [options] [executable-file [core-file or process-id]]
Options:
  --help             Print this message.
  --quiet            Do not print version number on startup.
  --fullname         Output information used by emacs-GDB interface.
  --epoch            Output information used by epoch emacs-GDB interface.
  --batch            Exit after processing options.
  --nx               Do not read .gdbinit file.
  --tty=TTY          Use TTY for input/output by the program being debugged.
  --cd=DIR           Change current directory to DIR.
  --directory=DIR    Search for source files in DIR.
  --command=FILE     Execute GDB commands from FILE.
  --symbols=SYMFILE  Read symbols from SYMFILE.
  --exec=EXECFILE    Use EXECFILE as the executable.
  --se=FILE          Use FILE as symbol file and executable file.
  --core=COREFILE    Analyze the core dump COREFILE.
  -b BAUDRATE        Set serial port baud rate used for remote debugging.
  --mapped           Use mapped symbol files if supported on this system.
  --readnow          Fully read symbol files on first access.
  --nw               Do not use a window interface.
  --kernel           Enable kernel debugging.
  --wcore            Make core file writable (only works for /dev/mem).
                     This option only works while debugging a kernel !!

For more information, type "help" from within GDB, or consult the
GDB manual (available as on-line info or a printed manual).
0
Comment
Question by:Dooglave
1 Comment
 
LVL 34

Accepted Solution

by:
Duncan Roe earned 500 total points
ID: 34211567
I don't have a kernel built with debug symbols, so I couldn't try this properly. But on a modern system it should work to miss out -k and -wcore and use /dev/core instead of /dev/mem.
My "modern" system is Linux 2.6.32 and gdb 7.1.
I found an older gdb (rev 5.3) but even that didn't recognise -wcore. If your gdb recognises -wcore then you could leave it (but you won't know whether it does until you omit -k).
You will know that /dev/mem is wrong if gdb reports it is not a core file
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question