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,063 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now