Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
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
Medium Priority
?
1,076 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
Duncan Roe earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

721 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