0

I'm building the dnstracer application from source with this script:

#!/bin/bash
#########
# FILES #
#########
PACKAGE_NAME=dnstracer-1.6
PACKAGE_TAR_FILE=${PACKAGE_NAME}.tar.gz    
PACKAGE_FTP_SITE=http://ftp.iij.ad.jp/pub/linux/momonga/1/PKGS/SOURCES/

####################################
# REMOVE OLD STUFF JUST TO BE SURE #
####################################
rm -rf build
rm -rf ${PACKAGE_NAME}
rm -rf ${PACKAGE_TAR_FILE}

#####################################
# Get source code for buggy package #
#####################################
wget ${PACKAGE_FTP_SITE}/${PACKAGE_TAR_FILE}

######################
# Unpack it here ... #
######################
tar xf ${PACKAGE_TAR_FILE}

##########################################
# Prepare an out of tree build directory #
##########################################
mkdir build

##############################
# Get inside build directory #
##############################
cd build

#################
# Configure ... #
#################
../${PACKAGE_NAME}/configure

###############
# Make it !!! #
###############
make -j

And I see it ships with its own getopt, which is good for me because I need to debug it:

$ ls -l ./dnstracer-1.6/getopt.*
./dnstracer-1.6/getopt.c
./dnstracer-1.6/getopt.h

However when I try to step inside getopt from gdb, I realize that it probably has some other getopt (maybe without debug symbols?) and it doesn't let me step inside:

$ cd build
$ gdb --args ./dnstracer -v aaaaaa
$ (gdb) break main
$ (gdb) run
$ (gdb) next
$ 1304 while ((ch=getopt(argc,argv,"coq:r:s:t:v"))!=-1) {
$ step
$ 1305 switch (ch) {

How can I configure the build process to use the shipped getopt version rather than some hidden default? Thanks!

OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87

1 Answers1

2

And I see it ships with its own getopt, which is good for me because I need to debug it:

Since you are on Ubuntu this is not the case for you, see in shipped getopt.h:

// Only used in the win32-version of dnstracer.
// Supplied by Mike Black <mblack@csihq.com>

Therefore you are using system getopt which is part of glibc. In order to step into getopt you need glibc debug symbols installed. See https://stackoverflow.com/a/48287761/72178 on how to debug glibc on Ubuntu.

ks1322
  • 33,961
  • 14
  • 109
  • 164
  • Thanks, I actually need to change getopt, but only want to do it ad hoc, for dnstracer. I've tried tricking the configure to think I'm on windows with: WIN32=1 ../${PACKAGE_NAME}/configure ... but still no go ... it uses the glibc getopt ... – OrenIshShalom Mar 05 '18 at 12:54