help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Debugging Octave (as in gdb not a script)


From: Alec Teal
Subject: Re: Debugging Octave (as in gdb not a script)
Date: Sun, 3 Feb 2013 00:12:18 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2

On 03/02/13 00:06, Sergei Steshenko wrote:



----- Original Message -----
From: Alec Teal <address@hidden>
To: Sergei Steshenko <address@hidden>
Cc: Juan Pablo Carbajal <address@hidden>; "address@hidden" <address@hidden>
Sent: Sunday, February 3, 2013 1:47 AM
Subject: Re: Debugging Octave (as in gdb not a script)

On 02/02/13 23:18, Sergei Steshenko wrote:


  ----- Original Message -----
  From: Alec Teal <address@hidden>
  To: Juan Pablo Carbajal <address@hidden>
  Cc: address@hidden
  Sent: Sunday, February 3, 2013 1:06 AM
  Subject: Re: Debugging Octave (as in gdb not a script)

  [snip]
  You can't use gdb on shell scripts.

  Alec

  _______________________________________________
  Help-octave mailing list
  address@hidden
  https://mailman.cae.wisc.edu/listinfo/help-octave

  But one can invoke 'gdb' from the innermost shell script.

  Regards,
     Sergei.


 From what I can tell the two shell scripts do nothing useful(?! why
have them?) and within the hidden folder src/.libs there exists a binary
called lt-octave

To any future people who have this problem - point the IDE to it, I do
not know why it is hidden or so far from the root-directory, if I find
out I will follow up but it doesn't seem to matter......

Alec

Well, in my case:

"
file /home/sergei/AFSWD/install/octave-3.6.2/bin/octave-3.6.2
/home/sergei/AFSWD/install/octave-3.6.2/bin/octave-3.6.2: ELF 32-bit LSB 
executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.4, dynamically 
linked (uses shared libs), not stripped
"

- this is self-built Octave.

So I am sure where the shell script comes form.

Regards,
   Sergei.



address@hidden ~/octave $ ls -l -a -h
total 4.8M
drwxr-xr-x 18 alec alec  12K Feb  2 23:16 .
drwx------ 67 alec alec  20K Feb  2 23:10 ..
-rw-r--r--  1 alec alec  60K Feb  2 20:12 aclocal.m4
-rw-r--r--  1 alec alec 6.7K Feb  2 21:08 AUTHORS
drwxr-xr-x  2 alec alec 4.0K Feb  2 20:21 autom4te.cache
-rwxr-xr-x  1 alec alec  29K Jan 17 19:51 bootstrap
-rw-r--r--  1 alec alec 4.5K Jan 17 19:51 bootstrap.conf
-rw-r--r--  1 alec alec  13K Feb  2 21:08 BUGS
drwxr-xr-x  3 alec alec 4.0K Feb  2 20:11 build-aux
-rw-r--r--  1 alec alec 103K Feb  2 20:32 config.h
-rw-r--r--  1 alec alec  99K Feb  2 20:14 config.h.in
-rw-r--r--  1 alec alec  99K Jan 17 19:56 config.h.in~
-rw-r--r--  1 alec alec 1.2M Feb  2 23:16 config.log
-rwxr-xr-x  1 alec alec 156K Feb  2 23:16 config.status
-rwxr-xr-x  1 alec alec 1.9M Feb  2 23:15 configure
-rw-r--r--  1 alec alec  94K Feb  2 20:11 configure.ac
-rw-r--r--  1 alec alec  35K Jan 17 19:51 COPYING
-rw-r--r--  1 alec alec 5.4K Feb  2 19:46 .cproject
-rw-r--r--  1 alec alec  396 Jan 17 19:48 .dir-locals.el
drwxr-xr-x  6 alec alec 4.0K Feb  2 23:16 doc
drwxr-xr-x  3 alec alec 4.0K Feb  2 20:11 etc
drwxr-xr-x  4 alec alec 4.0K Feb  2 23:16 examples
-rw-r--r--  1 alec alec 2.1K Feb  2 19:23 .gdbinit
-rw-r--r--  1 alec alec   50 Jan 17 19:48 .gitignore
drwxr-xr-x 11 alec alec 4.0K Jan 17 19:51 gnulib-hg
drwxr-xr-x  4 alec alec 4.0K Feb  2 20:11 .hg
-rw-r--r--  1 alec alec  951 Jan 17 19:48 .hgignore
-rw-r--r--  1 alec alec   22 Jan 17 19:48 .hgsub
-rw-r--r--  1 alec alec   51 Jan 17 19:51 .hgsubstate
-rw-r--r--  1 alec alec 3.8K Jan 17 19:51 .hgtags
lrwxrwxrwx  1 alec alec   21 Jan 17 19:57 INSTALL -> gnulib-hg/doc/INSTALL
-rw-r--r--  1 alec alec  34K Feb  2 21:08 INSTALL.OCTAVE
drwxr-xr-x  5 alec alec  52K Feb  2 23:16 libgnu
drwxr-xr-x  8 alec alec 4.0K Feb  3 00:01 libgui
drwxr-xr-x 12 alec alec 4.0K Feb  2 23:59 libinterp
drwxr-xr-x 10 alec alec 4.0K Feb  2 23:34 liboctave
-rwxr-xr-x  1 alec alec 298K Feb  2 23:16 libtool
drwxr-xr-x  2 alec alec  36K Feb  2 20:21 m4
-rw-r--r--  1 alec alec 101K Feb  2 23:16 Makefile
-rw-r--r--  1 alec alec 3.7K Jan 17 19:51 Makefile.am
-rw-r--r--  1 alec alec  96K Feb  2 20:13 Makefile.in
-rw-r--r--  1 alec alec  52K Jan 17 19:51 NEWS
-rw-r--r--  1 alec alec    0 Feb  2 22:07 octave-workspace
-rw-r--r--  1 alec alec 2.3K Feb  2 18:10 .project
-rw-r--r--  1 alec alec 3.1K Jan 17 19:51 README
-rwxr-xr-x  1 alec alec 3.4K Feb  2 23:16 run-octave
-rw-r--r--  1 alec alec 3.3K Feb  2 20:11 run-octave.in
drwxr-xr-x 30 alec alec 4.0K Feb  3 00:01 scripts
drwxr-xr-x  2 alec alec 4.0K Feb  2 18:59 .settings
drwxr-xr-x  4 alec alec 4.0K Feb  3 00:01 src
-rw-r--r--  1 alec alec   23 Feb  2 23:16 stamp-h1
drwxr-xr-x  9 alec alec  12K Feb  2 23:16 test

No folder called bin, but I haven't installed octave, just compiled it.

address@hidden ~/octave $ cat ./run-octave
#! /bin/sh
##
## run-octave -- run Octave in the build tree.
##
## Copyright (C) 2006-2012 John W. Eaton
##
## This file is part of Octave.
##
## Octave is free software; you can redistribute it and/or modify it
## under the terms of the GNU General Public License as published by the
## Free Software Foundation; either version 3 of the License, or (at
## your option) any later version.
##
## Octave is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
## for more details.
##
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, see
## <http://www.gnu.org/licenses/>.

AWK=gawk
FIND=find
SED=/bin/sed

# FIXME -- is there a better way to handle the possibility of spaces
# in these names?

top_srcdir='/home/alec/octave'
builddir='/home/alec/octave'

d1="$top_srcdir/scripts"
d2="$builddir/scripts"
d3="$builddir/libinterp"

d1_list=`$FIND "$d1" -type d -a ! \( \( -name private -o -name '@*' \) -a -prune \) -exec echo '{}' ';' | $SED 's/$/:/'` d2_list=`$FIND "$d2" -type d -a ! \( \( -name private -o -name '@*' \) -a -prune \) -exec echo '{}' ';' | $SED 's/$/:/'` d3_list=`$FIND "$d3" -type d -a ! \( \( -name private -o -name '@*' \) -a -prune \) -exec echo '{}' ';' | $SED 's/$/:/'`

d1_path=`echo "$d1_list" | $AWK '{ t = (s $0); s = t; } END { sub (/:$/, "", s); print s; }'` d2_path=`echo "$d2_list" | $AWK '{ t = (s $0); s = t; } END { sub (/:$/, "", s); print s; }'` d3_path=`echo "$d3_list" | $AWK '{ t = (s $0); s = t; } END { sub (/:$/, "", s); print s; }'`

octave_executable="$builddir/src/octave"

LOADPATH="$d1_path:$d2_path:$d3_path"
IMAGEPATH="$top_srcdir/scripts/image"
DOCFILE="$builddir/doc/interpreter/doc-cache"
BUILT_IN_DOCSTRINGS_FILE="$builddir/libinterp/DOCSTRINGS"
TEXIMACROSFILE="$top_srcdir/doc/interpreter/macros.texi"
INFOFILE="$top_srcdir/doc/interpreter/octave.info"

## Checking for string equality below with prepended x's in order to
## handle problems with empty strings.
if [ $# -gt 0 ]; then
  if [ "x$1" = "x-g" ]; then
    driver="gdb --args"
    shift
  elif [ "x$1" = "x-gud" ]; then
    ## Frontends for gdb (e.g. Emacs's GUD mode) need --annotate=3
    driver="gdb --annotate=3 --args"
    shift
  elif [ "x$1" = "x-gud2" ]; then
## The latest version of gud needs -i=mi. There isn't a good way to check
    ## this at configure time, so we just add a gdb2 flag
    driver="gdb -i=mi --args"
    shift
  elif [ "x$1" = "x-valgrind" ]; then
    driver="valgrind --tool=memcheck"
    shift
  elif [ "x$1" = "x-strace" ]; then
    driver="strace -o octave.trace"
    shift
  elif [ "x$1" = "x-cli" ]; then
    octave_executable="$builddir/src/octave-cli"
    shift
  fi
fi

OCTAVE_SITE_INITFILE="$top_srcdir/scripts/startup/main-rcfile" \
OCTAVE_DEFAULT_QT_SETTINGS="$top_srcdir/libgui/default-qt-settings" \
OCTAVE_LOCALE_DIR="$top_srcdir/libgui/languages" \
OCTAVE_JAVA_DIR="$builddir/scripts/java" \
  exec $builddir/libtool --mode=execute $driver \
    "$octave_executable" --no-init-path --path="$LOADPATH" \
    --image-path="$IMAGEPATH" --doc-cache-file="$DOCFILE" \
    --built-in-docstrings-file="$BUILT_IN_DOCSTRINGS_FILE" \
    --texi-macros-file="$TEXIMACROSFILE" --info-file="$INFOFILE" "$@"


and:
address@hidden ~/octave $ ls ./src/ -a -h -l
total 472K
drwxr-xr-x  4 alec alec 4.0K Feb  3 00:01 .
drwxr-xr-x 18 alec alec  12K Feb  2 23:16 ..
drwxr-xr-x  2 alec alec 4.0K Feb  3 00:01 .deps
drwxr-xr-x  2 alec alec 4.0K Feb  3 00:01 .libs
-rw-r--r--  1 alec alec 1.2K Jan 17 19:51 main.cc
-rw-r--r--  1 alec alec 1016 Jan 17 19:51 main-cli.cc
-rw-r--r--  1 alec alec 2.5K Feb  3 00:01 main-cli.o
-rw-r--r--  1 alec alec 101K Feb  2 23:16 Makefile
-rw-r--r--  1 alec alec 3.9K Jan 17 19:51 Makefile.am
-rw-r--r--  1 alec alec 102K Feb  2 20:13 Makefile.in
-rwxr-xr-x  1 alec alec  15K Feb  3 00:01 mkoctfile
-rw-r--r--  1 alec alec  25K Jan 17 19:51 mkoctfile.in.cc
-rw-r--r--  1 alec alec  15K Jan 17 19:51 mkoctfile.in.sh
-rwxr-xr-x  1 alec alec 7.8K Feb  3 00:01 octave
-rwxr-xr-x  1 alec alec 7.7K Feb  3 00:01 octave-cli
-rwxr-xr-x  1 alec alec 6.8K Feb  3 00:01 octave-config
-rw-r--r--  1 alec alec 7.3K Jan 17 19:51 octave-config.in.cc
-rw-r--r--  1 alec alec 6.3K Jan 17 19:51 octave-config.in.sh
-rw-r--r--  1 alec alec 2.7K Feb  3 00:01 octave-main.o

here octave is a script

address@hidden ~/octave $ cat ./src/octave
#! /bin/bash

# octave - temporary wrapper script for .libs/octave
# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1
#
# The octave program cannot be directly executed until all the libtool
# libraries that it depends on are installed.
#
# This wrapper script should never be moved out of the build directory.
# If it is, it will not operate correctly.

# Sed substitution that helps us do robust quoting.  It backslashifies
# metacharacters that are still active within double-quoted strings.
sed_quote_subst='s/\([`"$\\]\)/\\\1/g'

# Be Bourne compatible
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
  emulate sh
  NULLCMD=:
  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
  # is contrary to our usage.  Disable this feature.
  alias -g '${1+"$@"}'='"$@"'
  setopt NO_GLOB_SUBST
else
  case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
fi
BIN_SH=xpg4; export BIN_SH # for Tru64
DUALCASE=1; export DUALCASE # for MKS sh

# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH

relink_command="(cd /home/alec/octave/src; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/home/alec/workspace/Mercury Compiler/src/:/usr/local/cuda-5.0/bin:/home/alec/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games\"; export PATH; g++ -I/usr/include/freetype2 -Wall -W -Wshadow -Wold-style-cast -Wformat -Wpointer-arith -Wwrite-strings -Wcast-align -Wcast-qual -O3 -pthread -o \$progdir/\$file octave-main.o ../libgui/.libs/liboctgui.so ../libinterp/.libs/liboctinterp.so ../liboctave/.libs/liboctave.so -lutil -lm -pthread -Wl,-rpath -Wl,/home/alec/octave/libgui/.libs -Wl,-rpath -Wl,/home/alec/octave/libinterp/.libs -Wl,-rpath -Wl,/home/alec/octave/liboctave/.libs -Wl,-rpath -Wl,/usr/local/lib/octave/3.7.1+)"

# This environment variable determines our operation mode.
if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
  # install mode needs the following variables:
  generated_by_libtool_version='2.4.2'
notinst_deplibs=' ../libgui/liboctgui.la ../libinterp/liboctinterp.la ../liboctave/liboctave.la'
else
  # When we are sourced in execute mode, $file and $ECHO are already set.
  if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
    file="$0"

# A function that is used when there is no print builtin or printf.
func_fallback_echo ()
{
  eval 'cat <<_LTECHO_EOF
$1
_LTECHO_EOF'
}
    ECHO="printf %s\\n"
  fi

# Very basic option parsing. These options are (a) specific to
# the libtool wrapper, (b) are identical between the wrapper
# /script/ and the wrapper /executable/ which is used only on
# windows platforms, and (c) all begin with the string --lt-
# (application programs are unlikely to have options which match
# this pattern).
#
# There are only two supported options: --lt-debug and
# --lt-dump-script. There is, deliberately, no --lt-help.
#
# The first argument to this parsing function should be the
# script's ../libtool value, followed by no.
lt_option_debug=
func_parse_lt_options ()
{
  lt_script_arg0=$0
  shift
  for lt_opt
  do
    case "$lt_opt" in
    --lt-debug) lt_option_debug=1 ;;
    --lt-dump-script)
lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'`
        test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=.
lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'`
        cat "$lt_dump_D/$lt_dump_F"
        exit 0
      ;;
    --lt-*)
        $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2
        exit 1
      ;;
    esac
  done

  # Print the debug banner immediately:
  if test -n "$lt_option_debug"; then
echo "octave:octave:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1" 1>&2
  fi
}

# Used when --lt-debug. Prints its arguments to stdout
# (redirection is the responsibility of the caller)
func_lt_dump_args ()
{
  lt_dump_args_N=1;
  for lt_arg
  do
    $ECHO "octave:octave:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg"
    lt_dump_args_N=`expr $lt_dump_args_N + 1`
  done
}

# Core function for launching the target application
func_exec_program_core ()
{

      if test -n "$lt_option_debug"; then
        $ECHO "octave:octave:${LINENO}: newargv[0]: $progdir/$program" 1>&2
        func_lt_dump_args ${1+"$@"} 1>&2
      fi
      exec "$progdir/$program" ${1+"$@"}

      $ECHO "$0: cannot exec $program $*" 1>&2
      exit 1
}

# A function to encapsulate launching the target application
# Strips options in the --lt-* namespace from $@ and
# launches target application with the remaining arguments.
func_exec_program ()
{
  case " $* " in
  *\ --lt-*)
    for lt_wr_arg
    do
      case $lt_wr_arg in
      --lt-*) ;;
      *) set x "$@" "$lt_wr_arg"; shift;;
      esac
      shift
    done ;;
  esac
  func_exec_program_core ${1+"$@"}
}

  # Parse options
  func_parse_lt_options "$0" ${1+"$@"}

  # Find the directory that this script lives in.
  thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'`
  test "x$thisdir" = "x$file" && thisdir=.

  # Follow symbolic links until we get to the real thisdir.
  file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'`
  while test -n "$file"; do
    destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'`

    # If there was a directory component, then change thisdir.
    if test "x$destdir" != "x$file"; then
      case "$destdir" in
      [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;;
      *) thisdir="$thisdir/$destdir" ;;
      esac
    fi

    file=`$ECHO "$file" | /bin/sed 's%^.*/%%'`
    file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'`
  done

  # Usually 'no', except on cygwin/mingw when embedded into
  # the cwrapper.
  WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no
  if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then
    # special case for '.'
    if test "$thisdir" = "."; then
      thisdir=`pwd`
    fi
    # remove .libs from thisdir
    case "$thisdir" in
*[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;;
    .libs )   thisdir=. ;;
    esac
  fi

  # Try to get the absolute directory name.
  absdir=`cd "$thisdir" && pwd`
  test -n "$absdir" && thisdir="$absdir"

  program=lt-'octave'
  progdir="$thisdir/.libs"

  if test ! -f "$progdir/$program" ||
{ file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \
       test "X$file" != "X$progdir/$program"; }; then

    file="$$-$program"

    if test ! -d "$progdir"; then
      mkdir "$progdir"
    else
      rm -f "$progdir/$file"
    fi

    # relink executable if necessary
    if test -n "$relink_command"; then
      if relink_command_output=`eval $relink_command 2>&1`; then :
      else
    printf %s\n "$relink_command_output" >&2
    rm -f "$progdir/$file"
    exit 1
      fi
    fi

    mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null ||
    { rm -f "$progdir/$program";
      mv -f "$progdir/$file" "$progdir/$program"; }
    rm -f "$progdir/$file"
  fi

  if test -f "$progdir/$program"; then
    if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then
      # Run the actual program with our arguments.
      func_exec_program ${1+"$@"}
    fi
  else
    # The program doesn't exist.
    $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2
    $ECHO "This script is just a wrapper for $program." 1>&2
    $ECHO "See the libtool documentation for more information." 1>&2
    exit 1
  fi
fi



As I said though, src/.libs/lt-octave works!

Alec



reply via email to

[Prev in Thread] Current Thread [Next in Thread]