sed works quite different in two servers - bash

I run below command with the same file on two servers, the test.txt size is 270m.
Server A runs only 9s, Server B runs about 1500s.
sed -i "s/aaa/bbb/g" test.txt;
I have checked the linux version and sed version by below command as well, they're almost the same except the server name. And both servers are with the same hardware set(3T mem, 64 core).
uname -a
Linux serverA 2.6.32-431.17.1.el6.x86_64 #1 SMP Fri Apr 11 17:27:00 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux
uname --version
uname (GNU coreutils) 8.4
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by David MacKenzie.
sed --version
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
GNU sed home page: <http://www.gnu.org/software/sed/>.
General help using GNU software: <http://www.gnu.org/gethelp/>.
E-mail bug reports to: <bug-gnu-utils#gnu.org>.
Be sure to include the word ``sed'' somewhere in the ``Subject:'' field.
Any idea to check the cause? Thanks a lot.

Two thing could explain that behaviour. The most probable is that the file resides on filesystems with different performances on each machine. Use the df command to learn what filesystem is used:
df -kh <path to the directory where the file is>
It could very well be that for the fast machine it is a local filesystem, and for the slow machine it is a remote (network) filesystem. Or both remote filesystem but one on a fast network and the other one on a slower network.
The other possibility would be that one machine is being heavily used by other processes, eating all the RAM for instance, or all the CPUs, while the other one is not. You can check the current global load of the machine with the uptime command.
The first step to find the culprit would be to verify the behaviour is reproduced every time, and then enquiry about the actual physical location of the file from each computer's point of view.

Related

Can't disable pagination in gdb

I can't seem to disable pagination in gdb. I've read all of the various answers suggesting to add set pagination off or set height 0 or set height unlimited to my ~/.gdbinit file, and I've tried all of them, but gdb seems to be ignoring them all. When I start gdb, it is clearly reading the ~/.gdbinit file, as I am able to set the auto-load safe-path, however every time I start, I have to hit enter again to start gdb, which is intensely frustrating. It's as if it's just completely ignoring the pagination off command. I've also tried adding these commands to the system-wide gdbinit (in /etc/gdb/gdbinit), but this didn't work either.
For what it's worth, I'm running Xubuntu 18.04 with GDB version (GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git). The .gdbinit file currently reads:
set auto-load safe-path /
#set height 0
#set height unlimited
set pagination off
EDIT: To clarify, for various reasons I have to have my terminal fairly short (~13 lines or so). When I start GDB, I am greeted by the following:
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
---Type <return> to continue, or q <return> to quit---
After hitting <return>, the rest of the intro message is displayed, and I can start using GDB. This is not desirable behaviour for me, and I would prefer if this pagination did not occur.
After hitting , the rest of the intro message is displayed, and I can start using GDB.
Reproduced.
The issue is that GDB prints the copyright banner before it reads ~/.gdbinit. Since the copyright doesn't fit, and since the .gdbinit hasn't yet been read, you get the pagination prompt.
Solution is trivial: suppress the copyright banner, like so: gdb -q ....

gdbserver - glob could not process pattern '(null)'

gdbserver localhost:2159 test_app.exe
Whenever I type this kind of command
I got this kind of message:
glob could not process pattern '(null)'.
Also, it doesn't matter which kind of terminal/CLI I use on my Windows machine -
the result is always the same.
I would like to debug my PDCurses/NCurses app via CLion.
Every time when it encounters the initscr() function CLion says to me that:
Redirection is not supported.
So the only workaround seems to be the usage of GDB Remote Debug.
But due to the problem described above I am not sure if my settings are correct.
$ gdbserver --version
GNU gdbserver (GDB) 8.1
Copyright (C) 2018 Free Software Foundation, Inc.
gdbserver is free software, covered by the GNU General Public License.
This gdbserver was configured as "x86_64-w64-mingw32"

kgdb virtualbox target returning error code 22

I'm trying to debug a live Linux kernel running on virtualbox. I added the appropriate settings in the kernel (using the .config file, by enabling KGDB and adding the debug info in the kernel).
My serial port is a named pipe (socket) which I then redirect using socat to get the corresponding PTY.
$ socat -d -d ./slackpipe PTY
2015/03/16 00:04:02 socat[2723] N opening connection to AF=1 "./slackpipe"
2015/03/16 00:04:02 socat[2723] N successfully connected from local address AF=1 "\x82q\xEE\x7E"
2015/03/16 00:04:02 socat[2723] N successfully connected via <anon>
2015/03/16 00:04:02 socat[2723] N PTY is /dev/pts/15
2015/03/16 00:04:02 socat[2723] N starting data transfer loop with FDs [3,3] and [4,4]
Then I fire up gdb with the corresponding vmlinux file and target the PTY obtained from the socat above
$ gdb vmlinux
GNU gdb (Ubuntu 7.7-0ubuntu3.1) 7.7
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from vmlinux...done.
(gdb) c
The program is not being run.
(gdb) target remote /dev/pts/15
Remote debugging using /dev/pts/15
qTStatus: Target returns error code '22'.
kgdb_breakpoint () at kernel/kgdb.c:1748
1748 kernel/kgdb.c: No such file or directory.
qTStatus: Target returns error code '22'.
What I do not understand is, this never used to be happen earlier. All of a sudden this seems to be appearing.
Keen for your input

GDB 7.6 STL pretty print with gcc-4.8 and mac os 10.9

I'm struggling to get the pretty prints as described here in gdb working on my mac. I downloaded the latest gdb through macports and using gcc-4.8.
I loaded the ~/.gdbinit file and the printers are registered, but whenever I call
print myVector it gives me the raw output.
Any suggestions what I could do? Thanks a lot guys!
To have pretty printer with libc++ (new library used in Clang++/LLVM) use this new pretty printer:
https://github.com/koutheir/libcxx-pretty-printers
The .gdbinit is almost the same (see sample)
I've just tried with Eclipse Luna on OS X 10.10 and it works.
Any suggestions what I could do?
You can try to register pretty printers directly from gdb command line, bypassing .gdbinit file to narrow down the problem:
ks#ks-comp:~$ gdb -n
GNU gdb (GDB) 7.6.1-ubuntu
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) python
>import sys
>sys.path.insert(0, '/home/ks/stlPrettyPrinter')
>from libstdcxx.v6.printers import register_libstdcxx_printers
>register_libstdcxx_printers (None)
>end
(gdb)
Note, that I've checked out pretty printers in /home/ks/stlPrettyPrinter folder:
ks#ks-comp:~$ ls -a /home/ks/stlPrettyPrinter
. .. hook.in index.html libstdcxx Makefile.am Makefile.in patch.txt .svn
ks#ks-comp:~$
If you're using the STL implementation in libc++ (the default with clang), GDB won't know how to pretty print the STL containers
Switch to using GNU libstdc++, and STL pretty printing in gdb should work.
STL pretty printers are implemented as Python programs that know about the implementation details of the STL containers and are maintained along with the STL implementations.
libc++ does not ship STL pretty printers that confirm to the GDB Python pretty printer API
Since you got your gcc-4.8 from MacPorts and MacPorts: Using the Right Compiler claims that gcc-* defaults to libstdc++ you should just avoid passing the -stdlib= option when using gcc.

Win executable runs but calling command stalls on Cygwin command line

I'm rebuilding a flash loader utility for a TI chip and am facing a minor issue that's affecting my workflow. I'm using a 64-bit Win7 PC and rebuilding the utility using make on cygwin bash shell. make and cygwin version numbers below.
$ make -v
GNU Make 3.82.90
Built for i686-pc-cygwin
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ uname -a
CYGWIN_NT-6.1-WOW64 DEEDAA 1.7.15(0.260/5/3) 2012-05-09 10:25 i686 Cygwin
One step in the build process calls a previously generated utility (windows executable) to generate the bin file that is required for the TI processor.
../../AISUtils//HexAIS_OMAP-L138.exe -ini ../sft_hexais.ini -o ../sft_C6748_SPI_MEM.bin ../sft_C6748_SPI_MEM.out
After this command is called there is no progress seen on the cygwin command line. However, execution of the command does complete, generating the files specified in this step and proceeds with the steps that follow in the makefile. It's just that I can never regain control of this window. I always need to kill the window, start another instance of cygwin.
If I try to kill the cygwin window immediately I get the message below.
mintty
Processes are running in session
Close anyway?
If I wait a while (the time to complete the steps that follow), then I can kill the window without this message popping up.
The same command on the windows command line is executed without any stalls and I do regain my command line.
c:\ti\boot_tools\OMAP-L138_FlashAndBootUtils_2_40\OMAP-L138\GNU\AISUtils>HexAIS_OMAP-L138.exe -ini ..\sft\sft_hexais.ini
-o ..\sft\sft_C6748_SPI_MEM.bin ..\sft\sft_C6748_SPI_MEM.out
-----------------------------------------------------
TI AIS Hex File Generator for OMAP-L138
(C) 2012, Texas Instruments, Inc.
Ver. 1.27
-----------------------------------------------------
Begining the AIS file generation.
AIS file being generated for bootmode: UART.
Parsing the input object file, ..\sft\sft_C6748_SPI_MEM.out.
AIS file generation was successful.
Wrote 15464 bytes to file ..\sft\sft_C6748_SPI_MEM.bin.
Conversion is complete.
It seems to me that something about the way the command is constructed is pushing commands on to another shell or forcing it to run in the background. Any thoughts on what may be going on or steps I can try to debug the issue?
file format of the executable that stalls
$ file AISUtils/HexAIS_OMAP-L138.exe
AISUtils/HexAIS_OMAP-L138.exe: PE32 executable (console) Intel 80386 Mono/.Net assembly, for MS Windows
Link to TI wiki that explains the build process. The link provides general instructions on rebuilding the utility and is very unlikely to provide any specific information related to my question. I'm only including it in case someone needed more background about the tools or the process.
http://processors.wiki.ti.com/index.php/Rebuilding_the_Flash_and_Boot_Utils_Package
Thanks.
Running Windows console applications inside a Cygwin (MinTTY) terminal is usually a terrible idea.
Try running inside a Windows (cmd) console or using cygstart to launch in a new window (in a Makefile, -w would probably be useful too).

Resources