Claudio Jeker <cje...@diehard.n-r-g.com> wrote:

> On Thu, Dec 16, 2021 at 03:55:43PM +0800, Vladimir Nikishkin wrote:
> > Hello, everyone
> > 
> > Recently I had a problem: my system is losing network connectivity,
> > although the interface (vio0 on KVM) seemed up. Restarting the
> > connection with `ifconfig vio0 down` and `ifconfig vio0 up` restores the
> > connection.
> > 
> > However, when I timed the execution, I found that the second `up` can
> > take up to 15 minutes. (Hugely unexpected!) To find out where the
> > program is waiting, I decided to recompile ifconfig from source with
> > debugging and profiling support.
> > 
> > Slightly adjusting the commands provided by the Makefile, I came up with
> > the following commands:
> > 
> > ```
> > egcc -O0 -g -pg -fPIC  -Werror-implicit-function-declaration  -c ifconfig.c
> > egcc -O0 -g -pg -fPIC  -Werror-implicit-function-declaration  -c brconfig.c
> > egcc -O0 -g -pg -fPIC  -Werror-implicit-function-declaration  -c sff.c
> > egcc  -g -pg -shared -pie -o ifconfig ifconfig.o brconfig.o sff.o -lc -pg
> > ```
> > 
> > However, when I run ./ifconfig compiled like this, I am getting (besides
> > the output of ifconfig itself) the following error message:
> > 
> > ```
> > gmon.out: No such file or directory
> > ```
> > 
> > I find this unexpected. Compiling and linking a simple helloworld with
> > -pg -g seems to be working fine, and gmon.out is produced as expected.
> > 
> > What am I doing wrong? Is there something specific that needs to be
> > permitted to profile ifconfig?
> 
> I doubt the problem is in ifconfig(8) itself but more an ioctl that takes
> long to finish. Anyway for prfiling to work you need to neuter unveil() in
> ifconfig. e.g. by changing the code. With unveil on the gmon.out file
> written in the atexit handler can't be created.

Wrong tool being used to debug a userland program.  It is better to attach
a debugger to a -g executable.  Or use ktrace -di with kdump, to figure out
what system calls it is stuck in.

And I suspect you will quickly decide there is no problem in ifconfig..

Reply via email to