date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,391,274,358,000 |
Using a common command line tool like sed or awk, is it possible to join all lines that end with a given character, like a backslash?
For example, given the file:
foo bar \
bash \
baz
dude \
happy
I would like to get this output:
foo bar bash baz
dude happy
|
a shorter and simpler sed solution:
sed '
: again
/\\$/ {
N
s/\\\n//
t again
}
' textfile
or one-liner if using GNU sed:
sed ':x; /\\$/ { N; s/\\\n//; tx }' textfile
| How can you combine all lines that end with a backslash character? |
1,391,274,358,000 |
Consider a text file with the following entries:
aaa
bbb
ccc
ddd
eee
fff
ggg
hhh
iii
Given a pattern (e.g. fff), I would like to grep the file above to get in the output:
all_lines except (pattern_matching_lines U (B lines_before) U (A lines_after))
For example, if B = 2 and A = 1, the output with pattern = fff sho... |
don's might be better in most cases, but just in case the file is really big, and you can't get sed to handle a script file that large (which can happen at around 5000+ lines of script), here it is with plain sed:
sed -ne:t -e"/\n.*$match/D" \
-e'$!N;//D;/'"$match/{" \
-e"s/\n/&/$A;t" \
-e'... | How to grep-inverse-match and exclude "before" and "after" lines |
1,391,274,358,000 |
I want to print the odd-numbered and even-numbered lines from files.
I found this shell script which makes use of echo.
#!/bin/bash
# Write a shell script that, given a file name as the argument will write
# the even numbered line to a file with name evenfile and odd numbered lines
# in a text file called oddfile.
# -... |
As you asked “in one line”:
awk '{print>sprintf("%sfile.%d",NR%2?"odd":"even",PROCINFO["pid"])}' filename
Note that most of the code is due to your fancy output filename choice. Otherwise the following code would be enough to put odd lines in “line-1” and even lines in “line-0”:
awk '{print>"line-"NR%2}' filename
| Print odd-numbered lines, print even-numbered lines |
1,391,274,358,000 |
I have an embedded linux system using Busybox (OpenWRT) - so commands are limited. I have two files that look like:
first file
aaaaaa
bbbbbb
cccccc
mmmmmm
nnnnnn
second file
mmmmmm
nnnnnn
yyyyyy
zzzzzz
I need to merge these 2 lists into 1 file, and remove the duplicates. I don't have diff (space is limited) so ... |
I think
sort file1 file2 | uniq
aaaaaa
bbbbbb
cccccc
mmmmmm
nnnnnn
yyyyyy
zzzzzz
will do what you want.
Additional Documentation: uniq sort
| Merge two lists while removing duplicates |
1,391,274,358,000 |
I was reading this awk script
awk -F"=" '{OFS="=";gsub(",",";",$2)}1'
I want to know what is the function of 1 at the end of it.
|
An awk program is a series of condition-action pairs, conditions being outside of curly braces and actions being enclosed in them. A condition is considered false if it evaluates to zero or the empty string, anything else is true (uninitialized variables are zero or empty string, depending on context, so they are fals... | What is the meaning of '1' at the end of an awk script |
1,391,274,358,000 |
I've got an extreme problem, and all of the solutions I can imagine are complicated. According to my UNIX/Linux experience there must be an easy way.
I want to delete the first 31 bytes of each file in /foo/. Each file is long enough. Well, I'm sure somebody will deliver me a suprisingly easy solution I just can't ima... |
for file in /foo/*
do
if [ -f "$file" ]
then
dd if="$file" of="$file.truncated" bs=31 skip=1 && mv "$file.truncated" "$file"
fi
done
or the faster, thanks to Gilles' suggestion:
for file in /foo/*
do
if [ -f $file ]
then
tail +32c $file > $file.truncated && mv $file.truncated $file
... | Delete the first n bytes of files |
1,391,274,358,000 |
Is there a simple utility or script to columnate the output from one of my scripts? I have data in some form:
A aldkhasdfljhaf
B klajsdfhalsdfh
C salkjsdjkladdag
D lseuiorlhisnflkc
E sdjklfhnslkdfhn
F kjhnakjshddnaskjdh
but if this becomes two long, write the data in the following form (where still vertically ordered... |
column seems to be what you want:
$ cat file
A aldkhasdfljhaf
B klajsdfhalsdfh
C salkjsdjkladdag
D lseuiorlhisnflkc
E sdjklfhnslkdfhn
$ column file
A aldkhasdfljhaf D lseuiorlhisnflkc
B klajsdfhalsdfh E sdjklfhnslkdfhn
C salkjsdjkladdag F kjhnakjshddnaskjdh
| Split long output into two columns |
1,391,274,358,000 |
how to print the line in case the first field start with Linux1
for example:
echo Linux1_ver2 12542 kernel-update | awk '{if ($1 ~ Linux1 ) print $0;}'
the target is to print the line , while the first field start with Linux1
example of lines:
Linux1-new 36352 Version:true
Linux1-1625543 9847
Linux1:16254 846... |
One way:
echo "Linux1_ver2 12542 kernel-update" | awk '$1 ~ /^ *Linux1/'
| awk + print line only if the first field start with string as Linux1 |
1,469,380,359,000 |
I typed help while I was in the GDB but didn't find anything about step-into, step-over and step-out. I put a breakpoint in an Assembly program in _start (break _start). Afterwards I typed next and it finished the debugging. I guess it was because it finished _start and didn't step-into as I wanted.
|
help running provides some hints:
There are step and next instuctions (and also nexti and stepi).
(gdb) help next
Step program, proceeding through subroutine calls.
Usage: next [N]
Unlike "step", if the current source line calls a subroutine,
this command does not enter the subroutine, but instead steps over
the call,... | How to step-into, step-over and step-out with GDB? |
1,469,380,359,000 |
When I use GDB command add-symbol-file to load the symbol, GDB always asks me 'y or n', like this:
gdb> add-symbol-file mydrv.ko 0xa0070000
add symbol table from file "mydrv.ko" at
.text_addr = 0xa0070000
(y or n)
How to make it not ask and execute quietly?
|
gdb will ask you to confirm certain commands, if the value of the confirm setting is on. From Optional Warnings and Messages:
set confirm off
Disables confirmation requests. Note that running GDB with the --batch option (see -batch) also automatically disables confirmation requests.
set confirm on
Enables confir... | How to make gdb not ask me "y or n"? |
1,469,380,359,000 |
I wrote a program that calls setuid(0) and execve("/bin/bash",NULL,NULL).
Then I did chown root:root a.out && chmod +s a.out
When I execute ./a.out I get a root shell. However when I do gdb a.out it starts the process as normal user, and launches a user shell.
So... can I debug a setuid root program?
|
You can only debug a setuid or setgid program if the debugger is running as root. The kernel won't let you call ptrace on a program running with extra privileges. If it did, you would be able to make the program execute anything, which would effectively mean you could e.g. run a root shell by calling a debugger on /bi... | Can gdb debug suid root programs? |
1,469,380,359,000 |
I was reading the manpage for gdb and I came across the line:
You can use GDB to debug programs written in C, C@t{++}, Fortran and Modula-2.
The C@t{++} looks like a regex but I can't seem to decode it.
What does it mean?
|
GNU hates man pages, so they usually write documentation in another format and generate a man page from that, without really caring if the result is usable.
C@t{++} is some texinfo markup which didn't get translated. It wasn't intended to be part of the user-visible documentation. It should simply say C++ (possibly wi... | What does C@t{++} mean in the gdb man page? |
1,469,380,359,000 |
Is there a way to get a core dump (or something similar) for a process without actually killing the processes? I have a multithreaded python process running on an embedded system. And I want to be able to get a snapshot of the process under normal conditions (ie with the other processes required to be running), but I ... |
The usual trick is to have something (possibly a signal like SIGUSR1) trigger the program to fork(), then the child calls abort() to make itself dump core.
from os import fork, abort
(...)
def onUSR1(sig, frame):
if os.fork == 0:
os.abort
and during initialization
from signal import signal, SIGUSR1
from w... | Dump process core without killing the process |
1,469,380,359,000 |
I'm debugging using core dumps, and note that gdb needs you to supply the executable as well as the core dump. Why is this? If the core dump contains all the memory that the process uses, isn't the executable contained within the core dump? Perhaps there's no guarantee that the whole exe is loaded into memory (ind... |
The core dump is just the dump of your programs memory footprint, if you know where everything was then you could just use that.
You use the executable because it explains where (in terms of logical addresses) things are located in memory, i.e. the core file.
If you use a command objdump it will dump the meta data ab... | Why does GDB need the executable as well as the core dump? |
1,469,380,359,000 |
I was thrown off guard today by gdb:
Program exited with code 0146.
gdb prints the return code in octal; looking into why I found:
http://comments.gmane.org/gmane.comp.gdb.devel/30363
But that's not a particularly satisfying answer. Some quick googling did not reveal the history, so I was hoping someone on SO might k... |
The octal representation eases the interpretation of the exit code for small values, which are the most commonly used. Should this number, which is a byte, been printed in decimal, finding which signal interrupted a process would require a little bit of calculation while in octal, they can be read as they are:
a proc... | Unix History: return code octal? |
1,469,380,359,000 |
I made an alias ff and sourced it from ~/.zsh/aliases.zsh.
The aliases run well themselves:
alias ff
ff='firefox --safe-mode'
and it runs as expected.
But when I try to run it under gdb I get:
> gdb ff
GNU gdb (Debian 7.12-6+b1) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GN... |
Aliases are a feature of the shell. Defining an alias creates a new shell command name. It's recognized only by the shell, and only when it appears as a command name.
For example, if you type
> ff
at a shell prompt, it will invoke your alias, but if you type
> echo ff
the ff is just an argument, not a command. (At l... | why doesn't gdb like aliases [duplicate] |
1,469,380,359,000 |
When I debug an executable program with arguments arg1 arg2 with gdb I perform the following sequence
gdb
file ./program
run arg1 arg2
bt
quit
How can I do the same from one command line in shell script?
|
You can pass commands to gdb on the command line with option -ex. You need to repeat this for each command. This can be useful when your program needs to read stdin so you don't want to redirect it. Eg, for od -c
echo abc |
gdb -ex 'break main' -ex 'run -c' -ex bt -ex cont -ex quit od
So in particular for your ques... | gdb in one command |
1,469,380,359,000 |
Sometimes you need to unmount a filesystem or detach a loop device but it is busy because of open file descriptors, perhaps because of a smb server process.
To force the unmount, you can kill the offending process (or try kill -SIGTERM), but that would close the smb connection (even though some of the files it has ope... |
Fiddling with a process with gdb is almost never safe though may be
necessary if there's some emergency and the process needs to stay open
and all the risks and code involved is understood.
Most often I would simply terminate the process, though some cases may
be different and could depend on the environment, who owns... | Safest way to force close a file descriptor |
1,469,380,359,000 |
I am making a nice presentation of ARM assembly code execution and I would need GDB to step the code every 1 second infinitely long (well until I press CTRL+C). Has anyone got solution?
I don't want to keep on standing next to the keyboard and stepping the program when visitors come visit my stall.
|
Gdb's CLI supports a while loop. There's no builtin sleep command, but you can either call out to the shell to run the sleep program, or use gdb's builtin python interpreter, if it has one. It's interruptible with Control-C.
Method 1:
(gdb) while (1)
>step
>shell sleep 1
>end
Method 2:
(gdb) python import time
(... | GDB step in delays |
1,469,380,359,000 |
(gdb)printf "Hello %d", 7
Hello 7
(gdb)set $MyVar = printf "Hello %d", 7 // ???
How to save the result of printf "Hello %d", 7 to $MyVar?
|
eval does a printf of its arguments and then runs it as a command. So you can take your printf argument list, insert set $MyVar = at the beginning, and eval it.
(gdb) eval "set $MyVar = \"Hello %d\"", 7
(gdb) print $MyVar
$2 = "Hello 7"
| How to save the result of printf to a variable in GDB? |
1,469,380,359,000 |
This is the result of looking at virtual memory of a process in gdb; I have some questions regarding this:
Why are some parts of the virtual memory are repeated? For example, our program (stack6) and libc library is repeated 4 times; if they have partitioned them into different parts, then why? Why not just put the... |
There’s one important piece of information missing from gdb’s output: the pages’ permissions. (They’re shown on Solaris and FreeBSD, but not on Linux.) You can see those by looking at /proc/<pid>/maps; the maps for your Protostar example show
$ cat /proc/.../maps
08048000-08049000 r-xp 00000000 00:0f 2925 /opt/p... | Why some libraries and other parts get repeated in the linux virtual memory with gdb? |
1,469,380,359,000 |
My computer run with Ubuntu 14.04. GDB seems to be abnormal in different account. For example I make a very simple test. I write a file under ~/test/test.c like this:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
printf("hello,world");
return 0;
}
and build with command "gcc -g te... |
It appears that your SHELL variable is set to a file that doesn't exist. Try the following:
export SHELL=/bin/sh
gdb test
ensuring that /bin/sh exists and is executable. This works via su not because of root permissions, but because su resets the SHELL environment variable. Per the su manual page:
Note that the de... | GDB cannot exec my test program |
1,469,380,359,000 |
I am using a third party .NET Core application (a binary distribution used by a VS Code extension) that unfortunately has diagnostic logging enabled with no apparent way to disable it (I did already report this to the authors). The ideal solution (beside being able to disable it), would be if I could specify to system... |
In short, have your library loaded by LD_PRELOAD override syslog(3) rather than connect(3).
The /dev/log Unix socket is used by the syslog(3) glibc function, which connects to it and writes to it. Overriding connect(3) probably doesn't work because the syslog(3) implementation inside glibc will execute the connect(2) ... | How to prevent a process from writing to the systemd journal? |
1,469,380,359,000 |
I wished to know if someone knew how to put the compilation warnings of GCC in a text file ?
For example :
I wrote (willingly) a undefined function foo(). So gcc tell me :
warning: implicit declaration of function 'foo [Wimplicit-function-declaration]
How can i get this line written in a text file ? I search for an ... |
You can redirect the output, say your program is:
main()
{
}
When you compile, gcc will say something like:
a.c:1:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
main()
^~~~
That is shown in the terminal. What you want to do is redirect this to a file. In this case, you need to redirect the standar erro... | How can i put the gcc warning messages in a text file? [duplicate] |
1,469,380,359,000 |
Let me preface this question by saying that I've found a lot of answers for questions similar to my question but for 32-bit machines. However, I can't find anything for 64-bit machines. Please no answers with respect to 32-bit machines.
According to many sources on Stack Exchange, /proc/kcore can be literally dumped (... |
After a lot more searching I think I have convinced myself that there is no simple way to get what I want.
So, what did I end up doing? I installed LiME from github (https://github.com/504ensicsLabs/LiME)
git clone https://github.com/504ensicsLabs/LiMe
cd /LiME/src
make -C /lib/modules/`uname -r`/build M=$PWD modules
... | The structure of /proc/kcore on 64-bit machine and relation to physical memory |
1,469,380,359,000 |
When I try stepping through a program, gdb throws this error
std::ostream::operator<< (this=0x6013c0 <std::cout@@GLIBCXX_3.4>, __n=2)
at /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/ostream.tcc:110
110 /build/gcc/src/gcc-build/x86_64-unknown-linux-gnu/libstdc++-v3/include/bits/ostrea... |
I've filled a bug report against this issue: https://bugs.archlinux.org/task/47220
This happens because the ostream source file cannot be found.
Workaround 1
You can strip the libstdc++ library:
sudo strip /usr/lib/libstdc++.so.6
And then gdb will not try to open the source file and the error will not appear anymore.... | GDB throws error on Arch Linux |
1,469,380,359,000 |
I'm running a wheezy:armhf chroot using qemu user emulation on my jessie:x86_64 system. Somehow, a git clone on a particular private repository will hang inside the chroot, while succeed natively. This might be a bug, who knows? To improve my karma, I want to find out what's going on!
As a side-note: the hang I'm expe... |
Turns out that this particular hang of "git clone" is a qemu-related problem... Other problems in the qemu-user-emulation prevail, so I have to fall back to full-system emulation... ;-(
Using a qemu-user-static, compiled from their git (the qemu-2.0.0+dfsg-4+b1 currently in jessie has less fixes and won't work for my ... | Backtrace of "git clone" running inside qemu-user-emulation based arm-chroot |
1,469,380,359,000 |
I'm trying to debug Linux kernel using qemu and gdb. The problem is that gdb won't stop at the breakpoint. I've searched about it and found that turning kASLR off may help because kASLR confuses gdb.
-- Install that kernel on the guest.
+- Install that kernel on the guest, turn off KASLR by adding "nokaslr" to
the k... |
Kernel boot parameters can be set temporarily per boot or always via some configuration file; how this is done depends on the bootloader which for current versions of Ubuntu is grub2;
$ grep GRUB_CMDLINE_LINUX_DEFAULT /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
$ sudo perl -i -pe 'm/quiet/ and s//quiet nokasl... | Turning off kASLR to debug linux kernel using qemu and gdb |
1,469,380,359,000 |
Is there a way to measure elapsed time running the program under gdb?
Look to this:
<------------bp---------------------------------->
Assume that we are debugging a file and in some random place, we set a breakpoint. Now in gdb we perform something and then we let the program continue the execution by using the gdb ... |
The easiest way to do this (if your gdb has python support):
break *0xaddress
run
# target process is now stopped at breakpoint
python import time
python starttime=time.time()
continue
python print (time.time()-starttime)
If your gdb doesn't have python support but can run shell commands, then use this:
shell echo se... | Elapsed time in gdb |
1,469,380,359,000 |
When debugging it is often helpful to loot at assembly, but on Debian 9 when I try layout asm I get:
Undefined command: "layout". Try "help".
According to some internet research it seems like I need to have TUI enabled, but I'm not sure how to enable or install it.
|
The default installation from Debian 9's netinst ISO doesn't include gdb or C or C++ compilers. A user would typically run apt install build-essential gdb to install them.
In certain circumstances - I could reproduce this by using the netinst ISO and choosing to install KDE - the gdb-minimal package will be installed,... | How to enable TUI for gdb on Debian 9? |
1,469,380,359,000 |
GDB is telling me, that the program compiled with gcc -m32 (i386 program) is incompatible with my shared libraries (i386:x86-64).
Output of gdb:
(gdb) r
Starting program: /root/format
warning: `/libexec/ld-elf.so.1': Shared library architecture i386:x86-64 is not compatible with target architecture i386.
It would be... |
You do not tell anything about your system so I'll just make the most likely guess. You are running a 64 bit system and have not installed any 32 bit libraries. The simplest method is to simply add them from the installer:
bsdinstall
...and select lib32. You can run the installer at any time (not just first install)... | How can I install i386/x86 shared libraries on freebsd? |
1,469,380,359,000 |
I'm trying to debug a code using GDB in a Fedora machine. It produces this message each time I run it.
Missing separate debuginfos, use: debuginfo-install glibc-2.18-12.fc20.x86_64 libgcc-4.8.3-1.fc20.x86_64 libstdc++-4.8.3-1.fc20.x86_64
My questions:
Should these packages be in GDB by default?
What is the function ... |
No. gdb is packaged by a maintainer, glibc is packaged by another maintainer, gcc, libstdc and so on all all packaged by different maintainers. To package the debuginfo for these along with gdb would take considerable coordination. Each time one of the packages changed, the gdb maintainer would have to repackage an... | Missing separate debuginfos |
1,469,380,359,000 |
I am trying to debug a kernel running on QEMU with GDB.
The kernel has been compiled with these options:
CONFIG_DEBUG_INFO=y
CONFIG_GDB_SCRIPTS=y
I launch the kernel in qemu with the following command:
qemu-system-x86_64 -s -S -kernel arch/x86_64/boot/bzImage
In a separate terminal, I launch GDB from the same path a... |
I ran into the same problem and found the solution from the linux kernel newbies mailing list.
You should disable KASLR in your kernel command line with nokaslr option, or disable kernel option "Randomize the kernel memory sections" inside "Processor type and features" when you build your kernel image.
| Hardware breakpoint in GDB +QEMU missing start_kernel |
1,469,380,359,000 |
I've downloaded the GDB source:
git clone git://sourceware.org/git/binutils-gdb.git
now how do I generate the documentation from source as can be downloaded from: https://sourceware.org/gdb/current/onlinedocs/ ?
I'm especially interested in the HTML documentation, especially if it is possible to build a single page v... |
cd binutils-gdb/gdb
./configure
cd doc
make html MAKEINFO=makeinfo MAKEINFOFLAGS='--no-split'
ls *.html
This assumes that you have makeinfo installed; that should be something like apt-get install texinfo on debian-like systems.
| How to build the GDB documentation from source? |
1,469,380,359,000 |
I am trying to debug a segfault without code a binary in a nonstandard path (specifically in /frs/alg/alg/bin/) and I was noticing that the decompiled code has fewer symbols than when debugging under gdb. I am assuming that the debug symbols are detached, but Where should I look to find them?
|
Presumably the binary has detached debug information; if gdb is able to find this without any particular configuration, it should be in one of
a build-id based file under /usr/lib/debug/.build-id;
a .debug file alongside the binary;
a .debug file in /frs/alg/alg/bin/.debug;
a .debug file in /usr/lib/debug/frs/alg/alg... | How do I find detached debug symbols for decompilation? |
1,469,380,359,000 |
After a program is compiled and the binary file is generated, we can use objdump to disassemble the binary file and extract the assembly code and a lot of information.
However, using -j .text with objdump, it will disassembly the whole functions (glibc, OS functions, etc ... ) that I do not want.
I want to focus only ... |
I don't see a way to tell the objdump program from binutils or elfutils to limit disassembly to specific functions. There are a couple of workarounds, though.
Assume the list of functions we're interested in is in file list:
$ nm -P basicmath_small |
awk '{ if ($2 == "T" && $1 != "main" && substr($1,1,1) != "_") p... | How to disassembly multiple functions using Linux utility objdump? |
1,469,380,359,000 |
I want to emulate an ARM processor for running the assembly programs using QEMU in RHEL. I have installed QEMU but I still have problems in running the assembly program. I got the assembly program, memory map and the makefile from this link. However, if I run the below command,
qemu-system-arm -S -s -M versatilepb ... |
Alright, I figured out what am making wrong. I should actually run the make command which will create my object file and binary file. I got more information on running the command from this link. Now, I have to figure out how to install GDB to interact between the ARM and QEMU.
| QEMU for ARM programs with GDB [closed] |
1,603,617,720,000 |
I know the basics of how to use gdb. But I would like to learn some advanced debugging techniques using gdb. What are the best resources - books, blogs, tutorials - that any of you use regularly. I did look at this question: Tips or resources for learning advanced debugging techniques GDB in xcode but what I'm lookin... |
Norman Matloff's book on debugging: The Art of Debugging is quite good, though I don't know if you would consider it advanced. There is also his online tutorial, Guide to Faster, Less Frustrating Debugging, which might be an earlier version of the book.
There is also a tutorial My debugging tutorial, linked from the p... | what are some of the best resources to learn advanced debugging techniques using gdb? [closed] |
1,603,617,720,000 |
I'm building a continuous integration environment for a firmware codebase, programming an ARM Cortex M0 using a Segger JLink device and running tests on the target using gdb and Segger's RTT tool.
I have three processes I need to start from "expect":
The gdb server. This listens for a connection from...
The gdb clien... |
The problem is probably that the gdb server output is being blocked because no one reads it, so the gdb client is also blocked. You can get expect to read and ignore the rest of the output from gdb with
expect_background eof exit
which makes the last spawned command continue with its output until end-of-file is read... | Why does a gdb client fail to talk to its gdb server when started by this "expect" script? |
1,603,617,720,000 |
I'm having lots of problems with GDB; usually crashes and starts using 100% CPU until I kill the process using the activity monitor on the Mac (using Mavericks).
How do I remove GDB from my machine (using GDB 7.6.1)? I plan to install an older version (GDB 6.x.x) after uninstalling this version.
|
A quick solution would be to simply remove whole /usr/local in case you haven't installed anything else there (according to out little detour in comments, I think that is the case). So sudo mv /usr/local /usr/_local will get rid of whatever gunk is there (you can delete the directory later, when you're sure it contain... | Uninstalling GDB on a Mac |
1,603,617,720,000 |
I am running the following:
command: gcore 56058
output:
Missing separate debuginfo for /lib64/libdl.so.2
Try: zypper install -C "debuginfo(build-id)=dcca9c1f648bda0a7318a7c8844982c440e3e4a3"
Missing separate debuginfo for /lib64/librt.so.1
Try: zypper install -C "debuginfo(build-id)=a8648696e4118ee36ec41c9d75c0520c2... |
Compilers can be configured to generate extra information with the executable and/or libraries that aid debugging. With this extra information, your debugger can show the original source code and variable names amongst other things.
Unfortunately, this debugging information take up a lot of space on the system. Cons... | "Missing separate debuginfo for ..." when running gcore |
1,603,617,720,000 |
While doing post-mortem debugging of my x86-64 application, I've come across a strange symptom:
(gdb) p/x $xmm1
$8 = {v4_float = {<unavailable>, <unavailable>, <unavailable>, <unavailable>}, v2_double = {<unavailable>, <unavailable>}, v16_int8 = {<unavailable> <repeats 16 times>}, v8_int16 = {<unavailable>, <unavailab... |
It seems to be true that Linux doesn't save these registers for the crashed thread. I've tried
eu-readelf --notes myapp.core
and it only reported PRSTATUS and various signal-related info for the crash, but not FPREGSET. Amusingly, other threads do appear to have FPREGSET saved in the dump. So the file just lacks this... | Are FPU/SSE/AVX registers not saved in core dumps? |
1,603,617,720,000 |
GDB seems to hang everytime when I try run command from gdb prompt. When I ran ps, there are two gdb processes that have been spawned and pstack reveals the following -
15:47:02:/home/stufs1/pmanjunath/a2/Asgn2_code$ uname -a
SunOS compserv1 5.10 Generic_118833-24 sun4u sparc SUNW,Sun-Blade-1500
15:44:04:/home/stufs... |
The process that calls vfork() hangs because it is the vfork() parent and the child did borrow the process image at that time so it cannot run until the child finishes a call to_exit() or exec*().
So you need to find out why the exec*() hangs.
A typical reason for a hang in exec*() is a NFS hang or a traversal through... | GDB hangs forever on Solaris |
1,603,617,720,000 |
I am trying a debug a peculiar performance behavior
in the thumbnail-generating process for eog,
specifically gdk-pixbuf.
The minimal files to reproduce are here:
https://github.com/nbeaver/gdk-pixbuf-bug
The process tree looks like this:
systemd,1 splash
`-plasmashell,4366
`-konsole,6783
`-bash,6793... |
After hitting upon the right combination of web search keywords,
I am 90% sure this is a duplicate of this bug from December 15, 2018:
Slow thumbnail generation due to font issues
So I was investigating a slowdown in eog while auto-reloading SVG files, and
it seems the problem was in the thumbnail generation, which... | Debugging a slow thumbnailer process |
1,603,617,720,000 |
This is somewhat related to gdb set overwrite logging on should overwrite gdb.txt correct? .
Let's say I'm running a session of some application. For example purposes, let me take the example of qbittorrent again.
As shared before this is how a run happens -
$ gdb qbittorrent
(gdb) set logging overwrite on
(gdb) ... |
You can use signals for this. Before you start your program, set up USR1 or USR2 to break gdb without affecting the program:
handle SIGUSR1 nopass
Then you can run your program, and when you need to stop it, run kill -USR1 from another shell with the appropriate (child) pid. gdb will pause the application, and you ca... | How to quit an application running in gdb gracefully when the application isn't reponding. |
1,603,617,720,000 |
I have been trying to find the address of the SHELL environment variable in a program on a Ubuntu 12.04 machine. I have turned off ASLR.
I found similar posts : SO question and blog post
I have tried using the following in gdb
(gdb) x/s *((char **)environ)
but I get the message :
(gdb) No symbol "environ" in curre... |
Has your binary been stripped of its symbols? If so, there will be no symbol table and you will have no hope of finding this symbol. You can find out with readelf - here my hello binary does have its symbol table:
$ readelf -S hello | grep -i symtab
[28] .symtab SYMTAB 0000000000000000 000018f... | Using gdb to inspect environment variables |
1,603,617,720,000 |
I want to inject a bit-flip fault into a running program. For this purpose, I'm using gdb to insert a breakpoint into the target program and then flipping a single bit in a random-selected register. When I perform this instruction under gdb in Ubuntu, I got this error when trying to manipulate $eip:
(gdb) info r
...
... |
You should be using (int) to coerce the pointer to an int. And in your later tests you should not be using * to de-reference the pointer; you are fetching the memory that $eip points to.
(gdb) p/x (int)$eip
$4 = 0xf7eb9810
(gdb) p/x (int)$eip^1
$5 = 0xf7eb9811
(gdb) set $eip = (int)$eip^1
(gdb) p/x (int)$eip
$6 = 0x... | How can we perform an arithmetic operation on a register using GDB? [closed] |
1,603,617,720,000 |
This starts partially from why doesn't gdb like aliases
Now I put the following arguments -
gdb firefox-esr
(gdb) set logging file my-firefox-esr-1802018.log
(gdb) set pagination 0
(gdb) show logging
Future logs will be written to firefox-esr-020818.log.
Logs will be appended to the log file.
Output will be logged a... |
By default the directive set logging file in gdb will write to the current directory.
So, in your example, the log file would be written to the directory where firefox-esr is located, if the user being used has write rights on that directory.
So the answer is yes, to write the log file in your home directory, you have... | where does gdb put the log file? |
1,603,617,720,000 |
I have a CentOS 7 system. I need to attach my GDB to an already running application, but get the (apparently usual) "ptrace: Operation not permitted." error. Running GDB as root prevents the error, but I would rather not resort to this.
I have researched the issue and did find multiple answers stating that you simply ... |
Debugging a program that has privileges effectively gives the debugger the same privileges. Therefore, regardless of any security settings, debugging a program that has extra privileges must require the debugger to have at least all of these privileges. For example, a setuid program has the privileges of both the orig... | Debug a setuid binary as non-root |
1,603,617,720,000 |
I have this program in C.
#include <stdio.h>
#include <string.h>
char * pwd = "pwd0";
void print_my_pwd() {
printf("your pwd is: %s\n", pwd);
}
int check_pwd(char * uname, char * upwd) {
char name[8];
strcpy(name, uname);
if (strcmp(pwd, upwd)) {
printf("non authorized\n");
return 1;
}
printf(... |
So your program does the following. The check_pwd function allocates a buffer on the stack that you overflow so the return address is corrupted. You try and choose this corruption so that it points to another function, print_my_pwd, the :GUUUU string, if interpreted as a 64bit value on a little endian machine is 0x??0... | How to pass zeroes in the argument to the program [duplicate] |
1,603,617,720,000 |
I use Conque-GDB as a plugin in Vim.
Here is how my Vim now looks like:
As you see I also use the Nerdtree and I can easily change its size:
https://codeyarns.com/2014/05/08/how-to-change-size-of-nerdtree-window/
But I don't know how to change the size of Conque-GDB.
|
The ConqueGDB is a split in vim, so you can always resize it using vim commands, for example:
:resize +20
:res -20
Where +20 and -20 is the number of pixels that will be added or subtracted from the current split size.
The same way you can increase/decrease the sizing of the NERDTree:
:vertical resize +20
Not sure... | Conque-GDB in vim: how to set size |
1,603,617,720,000 |
So I was wondering how to stop gdb every time my variable (test_v) changes
I know
watch test_v
Do I do
watch test_v
stop
To stop the program every time the variable test_v changes?
|
You don't need to use stop to make the program stop when the variable changes. Just watch test_v is enough.
stop command is not for stopping the program, but only meant to be hooked so you can execute some commands automatically when the program stops. Example usage from the gdb manual:
define hook-stop
handle SIGALRM... | gdb: stop the program when the variable changes |
1,603,617,720,000 |
I have installed gdb and added -g option to my compilation command, but when I try (gdb) s or (gdb) n it says:
The program is not being run.
It only works when I try (gdb) r and goes and stops where my program stops because of it's error(that I could see this without gdb in command line).
How should I trace line-b... |
You need to define a breakpoint, for example
break main
Then
run
and gdb will start your program and stop when it enters main.
| How to trace line by line by "gdb" C/C++ code? [closed] |
1,603,617,720,000 |
In gdb, the usual instructions for debugging given are -
gdb $package
set logging on
set pagination 0
handle SIG33 pass nostop noprint
run
and of course than collecting backtraces and all. Of the above, what does
handle SIG33 pass nostop noprint
and where it should be used and where not ?
|
handle SIG33
tells gdb how to handle signal 33; in the version you give, pass means to pass the signal on, nostop tells the debugger not to stop when the signal is emitted, and noprint not to print anything.
This kind of directive is useful when debugging runtimes which use signals internally. Signal 33 is used on An... | what does `handle SIG33 pass nostop noprint` does when used in gdb |
1,603,617,720,000 |
I have a simple clock program that uses math.h functions. I am currently on Kubuntu 21.10, the GCC version is (Ubuntu 12.2.0-3ubuntu1) 12.2.0, and the GDB version is (Ubuntu 12.1-3ubuntu2) 12.1.
The program source code (although it might not be needed):
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <... |
The info you need is not in the math.h header file, it's in the source code of the C standard library. Unfortunately, as noted in the Service - Debuginfod documentation, the Ubuntu Debuginfod service currently does not provide that:
Currently, the service only provides DWARF information. There are
plans to make it al... | GDB fails to download debuginfo for math.h |
1,603,617,720,000 |
Actually, I was learning about the buffer overflow attack. So, can we figure out buffer address (I am using buffer variable in my program so that while writing in the buffer, I will make changes in the stack)?
|
Yes, as long as your variable isn’t optimised away.
For example, using ls with debug symbols:
gdb ls
>>> break main
>>> run
>>> print argv
$1 = (char **) 0x7fffffffdd78
In this case, argv is a pointer itself. If you want the address of a non-pointer variable, or the address of a pointer, use & as you would in C; gdb ... | Can we get address of a variable in a C program using GDB? |
1,603,617,720,000 |
For gdb debugger
(gdb) p &buffer
This command is used to print the content of starting of buffer (stack), or print the address?
If it is content, how to print the address?
|
It depends on what type the buffer is.
Most likely buffer is a pointer to the start of the buffer. The C-style declaration for it might be struct stackElement *buffer; or something similar (note the asterisk!).
In that case:
p &buffer prints the address where the pointer itself is stored (i.e. "the address of the ad... | GDB command to print the address of starting of buffer (stack) |
1,603,617,720,000 |
From the documentation link here: https://www.gnu.org/software/emacs/manual/html_node/emacs/Other-GDB-Buffers.html
When gdb-many-windows is non-nil, the locals buffer shares its window with the registers buffer, just like breakpoints and threads buffers. To switch from one to the other, click with mouse-1 on the rele... |
The answer seems to be a simple tab. The source gdb-mi.el has a defvar for gdb-locals-mode-map which seems to in place in the locals buffer. Look for use of the symbol header-line which is what the feature is called, and then symbols gdb-locals-buffer, gdb-locals-mode.
| Switching between shared buffers in emacs gdb mode without mouse (in text-terminal) |
1,603,617,720,000 |
Is it possible to dump the assembly language code of a binary using GDB?
I tried to use the "l" command but it says No symbol table is loaded. Use the "file" command.. I use the file command and it says the load symbol was loaded but when I try the "l" command again I see the same message. All I need is the whole ass... |
First off, don't apologize for a question. If you did prior research then you are fine. If you didn't take the time to google it, then do that first.
If you want the assembly of a program, then gdb might not be your program, instead try objdump; however, if you want to view the assembly while debugging use the gdb com... | Obtaining a code dump from a binary |
1,603,617,720,000 |
I am porting the driver for a USB device to Rocky Linux 9.3. Once the module is inserted, new logins by ssh are unresponsive. Blacklisting the module and rebooting restores normal functionality.
https://github.com/izot/lon-driver
With the module inserted, lsmod|grep u50 "Used By" goes from 0 to 1 about every 7 secs... |
I didn't port this line properly and it failed to set the .num field in struct tty_ldisc_ops.
//FIXME err = tty_register_ldisc(N_U50, &u50_ldisc);
err = tty_register_ldisc(&u50_ldisc);
The other part of my question (breaking at module_init()) was solved by setting a breakpoint in rtnl_link_register().... | How can I break at module_init()? This loadable kernel module is preventing SSH logins |
1,603,617,720,000 |
Every time I start gdb, the following information is displayed:
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2
Copyright (C) 2020 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 WARRAN... |
Yes, add the --silent option (aka -q, -quiet, --quiet, -silent and abbreviations thereof):
$ gdb --silent
>>>
| Start GDB with No Help Information |
1,656,615,160,000 |
I would like to find out which method my 32bit QEMU guest is using for system calls. There's an excellent article explaining linux-gate.dso (http://www.trilithium.com/johan/2005/08/linux-gate/). However, I can 't seem to get any of the commands to work on my newer system.
It appears that current security features don'... |
In order to read /proc/[pid]/mem, a process must now PTRACE_ATTACH to it. A commonly available utility that does this is gdb
Pick a running process (in my case I just opened cat in another window), then attach gdb to that process:
[root@qemu ~]# gdb --pid 423
#MORE OUTPUT
0xb771dbac in __kernel_vsyscall ()
As part of... | How do I get linux-gate.dso on a newer linux system? |
1,656,615,160,000 |
I have these lines in my .vimrc file:
:map <F9> :exe ':!gdbset bp "%:'.line(".").'"'<CR><CR>
:map <F8> :exe ':!gdbset clear bp "%:'.line(".").'"'<CR><CR>
They work great for adding and removing break points in gdb!
Only one problem (that I know of)... for some reason line numbers in the 80's don't work. If I put my ... |
%:8 is a valid filename-modifier, so it is being interpreted by Vim as a part of the :! command.
You can use expand('%') to manually expand %, and then properly quote it with shellescape(…,1):
:map <F9> :exe '!gdbset bp' shellescape(expand('%').':'.line('.'),1)<CR><CR>
:map <F8> :exe '!gdbset clear bp' shellesca... | vimrc mapping line numbers |
1,656,615,160,000 |
I'm encountering a weird behaviour with my endeavourOS system.
For context, it seems to have started happening after a malformed svg file made inkscape and my system crash, after which I needed to hard-reboot it.
With several apps (to list the last few I've tested : flameshot, keepassxc, quiterss) I've had a Bus error... |
fixed it,
Program received signal SIGBUS, Bus error.
memset () at ../sysdeps/x86_64/multiarch/../multiarch/memset-vec-unaligned-erms.S:244
led me to this github repo
I reinstalled glibc with :
sudo pacman -Syu glibc --overwrite "*"
and now everything is back to normal
edit : command modified thanks to killertofus' c... | Bus error (core dumped) on several apps |
1,656,615,160,000 |
I'm implementing some CTF challenges. The flags are in some text files, that get read from the programs. To protect the flags I have changed the owner of the files, but have set the setuid to the executables to be able to read the files. It works when I run my programs outside gdb, and the flags are read, but inside g... |
The security contract of setuid¹ is that it grants the executable program extra privileges. Those privileges are only granted to the program. They must not allow the invoking user to do anything that the program won't do.
This makes setuid incompatible with tracing (the ptrace system call on most Unix variants). If th... | Permission denied when opening a file in gdb |
1,656,615,160,000 |
P.S. English is not my native language; please excuse typing errors.
I've (maybe) understand the basically main idea of symbol in ELF file in dynamic link.
Refering to textbooks, if I need dynamic link to .so or something like that then I need the link target's function name(Say,If we only talk about the functions). T... |
In a number of distributions (Debian, Ubuntu, Fedora, etc.; but not Arch, as far as I can tell from the corresponding wiki page), programs are built with debugging information (see below), but that debugging information is then detached into separate files. These separate files are shipped in debug packages and/or th... | What does debug symbol actually mean on Arch linux for gdb debugging? |
1,656,615,160,000 |
I know that I can use CTRL+ALT+J in gdb to get vim keybindings but how do I get gdb to start in vi mode by default ?
|
Put set editing-mode vi in a .inputrc file in your home directory. bash, gdb, and other programs using readline will be in vi--mode by default.
Note that zsh does not use readline as a line editing library but zle and therefore you will need to set bindkey -v or set -o vi in your ~/.zshrc :
(https://unix.stackexchange... | How to have gdb start in vi mode by default? |
1,656,615,160,000 |
I have a java program that executes several shell files (one by each iteration).
The shell file only has one command, start cross-gdb with a path to a gdbinit file.
The program works fine, but (from NetBeans output window) the java program finishes its work and exits, but the terminal window never closes.
I have teste... |
You can try this
ProcessBuilder pbuilder = new ProcessBuilder("/shell");
and in the shell script
#! /bin/sh
export PATH=gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabi/bin:$PATH
nohup arm-linux-gnueabi-gdb --command=/home/null/Desktop/Gem5/gem5/patch.gdbinit &>/dev/null
What nohup does is it makes a command immune to ... | How to kill an orphan Terminal process |
1,656,615,160,000 |
Ive added gdbserver in the inetd.conf and etc/services yet when I attempt to connect as follows I immediately get Remote communication error. Target disconnected.: Broken pipe.
(gdb) target extended-remote rtx5:8010
Remote debugging using rtx5:8010
Remote communication error. Target disconnected.: Broken pipe.
8010 i... |
I managed to get it working by doing the following:
In inetd.conf "gdbserver --multi -" Using the dash apparently directs the server to use stdin and out.
I am interested to know why exactly this works.
| gdbserver as an inetdamon broken pipe |
1,656,615,160,000 |
I'm trying to get only the raw binary data from the gdb disassemble output.
My current output is the following:
$ gdb -batch -ex "disassemble/r btif_set_adapter_property" libbluetooth_qti.so | column -ts $'\t'
Dump of assembler code for function _Z25btif_set_adapter_propertyPK13bt_property_t:
0x0011e8c1 <+0>: ... |
You may be lucky with piping the GDB output through the following awk program:
awk '{for (i=1;i<=NF;i++) if ($i~/^[a-f0-9]{2}$/) printf("%s%s",$i,OFS)} END{print ""}'
This will check all "words" (space-separated chunks of text) of the incoming lines of GDB output and check if they are two-digit hex numbers. If so, i... | GDB Disassemble: Print only raw binary data (using column and awk) |
1,656,615,160,000 | ERROR: type should be string, got "\nhttps://git.postgresql.org/cgit/postgresql.git/tree/src/test/modules/delay_execution/delay_execution.c\nhttps://stackoverflow.com/questions/11967440/stepping-into-specific-function-in-gdb\nI loaded the module delay_execution.\nthen gdb -p $proc\nquite new to gdb. can I let gdb execute directly up to the beginning of delay_execution_planner?\nthere are many steps, press step by step seems not so good.\n" |
That's what breakpoints are for.
A simple
break delay_execution_planner
continue
does what you need.
| gdb execute through to a specific function |
1,656,615,160,000 |
I have a binary that I usually run as follows:
$ xvfb-run ./bin --param1 foo
However, now that I need to debug it using GDB, I'm not able to do:
$ gdb --args xvfb-run ./bin --param1 foo
because "/usr/bin/xvfb-run": not in executable format: file format not recognized.
Is there a way to do this? For example, by using... |
xvfb-run is a shell script! Hence, when you want to run all of xvfb-run it in gdb, you'd
gdb --args sh $(which xvfb-run) ./bin --param1 foo
But that's probably not what you want! Doesn't sound to me like you're interested in debugging the Xvfb X server itself. More like you're interested in debugging ./bin. You would... | How to debug (gdb) a binary that is invoked with xvfb-run? |
1,656,615,160,000 |
I searched all over the internet but couldn't find proper steps to debug linux module remotely using gdb. I am tring qemu but facing many issues there. Is there any other tool that I can use or if not then can you provide me proper steps to debug linux module remotely?
|
Shouldn't be that hard. From the official kernel documentation (don't search "all over the internet". Search the official documentation and you'll find less bad information):
Have a kernel that has KGBD enabled, and also make sure that during building the config option CONFIG_GDB_SCRIPTS is on. (Refer to documentatio... | How can I remotely debug linux module using GDB? |
1,656,615,160,000 |
Please see what does `handle SIG33 pass nostop noprint` does when used in gdb . I am guessing from the answer shared by Stephen Kitt, that info. about signals is in the source code somewhere. If I download the source code of a particular app, say leafpad http://tarot.freeshell.org/leafpad/ how can I search for which ... |
To find the signals that a given application handles, on its own, look for sigaction and signal calls in the source code. Libraries can also set up signal handlers, so you really need to look at those too...
Without looking at the source code, you can look for those using strace which has specific support for signal-r... | is there a way to know if signals are present in your application and which signals are there? [closed] |
1,656,615,160,000 |
I earlier had RDP access to a remote machine (a typical physical desktop PC) using which I launched a sudo apt dist-upgrade inside a GUI gnome-terminal. Since then I have lost the RDP connection and only have SSH[1]. Since there was no 'assume yes' in the apt command, inspecting cat /var/log/dist-upgrade/screenlog.0 o... |
I'm not entirely familiar with apt, but the name of that logfile (screenlog.0) makes me wonder if the process is already running under the control of screen? If that were the case, screen -ls should show an active session, and screen -R should re-attach to it.
If the log filename is a red herring, you may be able to r... | Pass Enter key to dist-upgrade's prompt, running inside a GUI terminal on a remote machine, accessible henceforth only over SSH |
1,656,615,160,000 |
source:https://git.postgresql.org/cgit/postgresql.git/tree/src/backend/optimizer/plan/planner.c
(gdb) n
3556 if (root->group_pathkeys)
(gdb) s
3558 else if (root->window_pathkeys)
(gdb) print root->group_pathkeys==NULL
No symbol "NULL" in current context.
(gdb) s
3559 root->que... |
print root->group_pathkeys
is normally enough to see if it is zero.
NULL is normally not known to the debugger because it is not declared but defined (may be #define NULL 0 or with cast to void as jian said.).
(This may be changed by size-expensive compilation flags.)
So you can replace NULL by 0. (Moreover, the deb... | gdb print out a pointer is null or not |
1,656,615,160,000 |
This is similar to the issue posted here and here. I want to reverse engineer a binary called gpslogger but before debugging it using GDB, I wish to simply emulate it using QEMU (qemu-aarch64) since when I run file gpslogger I get gpslogger: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked,... |
“interpreter /lib/ld-musl-aarch64.so.1” in file’s output indicates that gpslogger was built with musl. This means that you need not only the musl dynamic linker (ld-musl-aarch64.so.1), but you also need musl variants of every single library used by gpslogger.
The missing symbols you list indicate that the libraries yo... | Emulating an AARCH64 Binary calling libgps on x86_64 Ubuntu using QEMU gives "Error relocating: symbol not found" Errors |
1,656,615,160,000 |
Can you recommend me OS mentioned in Shellcoder's Handbook because I'm having frequent issues on running ELF files mentioned there(See the errors below). I know that to overcome those error I have to enter commands or arguments but I did that too and I'm still not getting same output as in the book like on the assembl... |
In the book output, you show that they disassemble _exit:
This GDB was configured as “i386-redhat-linux-gnu”...
(gdb) disas _exit
But in your experiment, you disassemble exit (notice the missing leading underscore):
This GDB was configured as "i686-linux-gnu"
gdb-peda$ disas exit
Those are two separate functions... | Red hat vs Ubuntu compile and assembly Problem(Book reference) |
1,656,615,160,000 |
Typing apt-get upgrade returns the following error:
dpkg: error processing package gdb (--configure):
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
Errors were encountered while processing:
gdb
E: Sub-process /usr/bin/dpkg returned an error code (1)
I tried a ... |
The error message gives some indication of what’s going on and how to fix it:
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
The problem is that the package state as described in dpkg’s “database” (the files under /var/lib/dpkg/info doesn’t match what’s on the s... | Error in dpkg when executing apt-get upgrade ( most of the commands ) |
1,656,615,160,000 |
If I had several hundred core dumps in a directory and want to filter it down to just ones generated by a specific signal without having to manually open each one in GDB one at a time, is there a way to do that?
GDB does allow you to pass in commands via -ex flag, but GDB's output doesn't go the console, so i can't ju... |
Partial answer:
I note you are using a conditional clause, so if the core dumps are not already generated, the easiest way is to include the signal in the name when they are generated. See man 5 core for details.
If you already have them, have a look at the details of the core format (see e.g. here). I'd assume the si... | Filter hundreds of coredumps by signal |
1,656,615,160,000 |
I'm debuging with gdb and need to define some helper commands. Basically I want my customized command to operate differently depending on the number of args given.
So I have to test whether $arg* is given, see the code below:
define pgdir
set $pgdir = $arg0
if ($arg1) {
// show the corresponding PDE... |
You can use the convenience function $_isvoid(). It returns 1 if the variable is void.
(gdb) set $v = 1
(gdb) print $_isvoid($v)
$1 = 0
(gdb) print $_isvoid($v2)
$2 = 1
| gdb-customize command, how to test whether a variable is set? |
1,656,615,160,000 |
Running pstack on a process sometimes causes gdb to attach to that process on one of my Linux servers. Why would pstack launch gdb, and how can I prevent that?
Details:
gdb is running as: /user/bin/gdb --quiet -nx /proc/1234/exe 1234
the parent process of gdb is: /bin/sh /user/bin/pstack 1234
|
Recent versions of pstack are standalone, but older versions (e.g. pstack-gdb, or the version of pstack in RHEL 5) are wrappers around gdb. Presumably “one of your servers” has an older distribution and its version of pstack is one of the gdb wrappers.
To prevent that, you’d have to install a newer version of pstack.
| Why does pstack launch gdb (and how to prevent it)? |
1,386,277,472,000 |
I have been trying to parallelize the following script, specifically each of the three FOR loop instances, using GNU Parallel but haven't been able to. The 4 commands contained within the FOR loop run in series, each loop taking around 10 minutes.
#!/bin/bash
kar='KAR5'
runList='run2 run3 run4'
mkdir normFunc
for ru... |
Why don't you just fork (aka. background) them?
foo () {
local run=$1
fsl5.0-flirt -in $kar"deformed.nii.gz" -ref normtemp.nii.gz -omat $run".norm1.mat" -bins 256 -cost corratio -searchrx -90 90 -searchry -90 90 -searchrz -90 90 -dof 12
fsl5.0-flirt -in $run".poststats.nii.gz" -ref $kar"deformed.nii.gz" -... | Parallelize a Bash FOR Loop |
1,386,277,472,000 |
I'm confused about the difference or advantage (if any) of running a set of tasks in a .sh script using GNU parallel
E.g. Ole Tange's answer:
parallel ./pngout -s0 {} R{} ::: *.png
rather than say looping through them putting them in the background &.
E.g. frostschutz's answer:
#copied from the link for illustration
... |
Putting multiple jobs in the background is a good way of using the multiple cores of a single machine. parallel however, allows you to spread jobs across multiple servers of your network. From man parallel:
GNU parallel is a shell tool for executing jobs in parallel using
one or more computers. The typical input i... | GNU parallel vs & (I mean background) vs xargs -P |
1,386,277,472,000 |
I have been using a rsync script to synchronize data at one host with the data at another host. The data has numerous small-sized files that contribute to almost 1.2TB.
In order to sync those files, I have been using rsync command as follows:
rsync -avzm --stats --human-readable --include-from proj.lst /data/projects ... |
Following steps did the job for me:
Run the rsync --dry-run first in order to get the list of files those would be affected.
$ rsync -avzm --stats --safe-links --ignore-existing --dry-run \
--human-readable /data/projects REMOTE-HOST:/data/ > /tmp/transfer.log
I fed the output of cat transfer.log to parallel in... | Parallelise rsync using GNU Parallel |
1,386,277,472,000 |
echo 'echo "hello, world!";sleep 3;' | parallel
This command does not output anything until it has completed. Parallel's man page claims:
GNU parallel makes sure output from the commands is the same output as you would get had you run the commands sequentially.
I guess the devil is in the phrasing: you get the same... |
I think you're looking for --ungroup. The man page says:
--group Group output. Output from each jobs is grouped
together and is only printed when the command is finished.
--group is the default. Can be reversed with -u.
-u of course is a synonym for --ungroup.
| Can GNU parallel output stdout before the program has exited? |
1,386,277,472,000 |
I have a shell scripting problem where I'm given a directory full of input files (each file containing many input lines), and I need to process them individually, redirecting each of their outputs to a unique file (aka, file_1.input needs to be captured in file_1.output, and so on).
Pre-parallel, I would just iterate ... |
GNU Parallel is designed for this kind of tasks:
parallel customScript -c 33 -I -file {} -a -v 55 '>' {.}.output ::: *.input
or:
ls | parallel customScript -c 33 -I -file {} -a -v 55 '>' {.}.output
It will run one jobs per CPU core.
You can install GNU Parallel simply by:
wget https://git.savannah.gnu.org/cgit/paral... | using parallel to process unique input files to unique output files |
1,386,277,472,000 |
In a larger script to post-process some simulation data I had the following line:
parallel bnzip2 -- *.bz2
Which, if I understand parallel correctly (and I may not), should run n-core threads of the program over all files with the listed extension. You may notice that I misspelled the command bunzip2. I would expect ... |
You have been hit by the confusion with Tollef's parallel from moreutils. See https://www.gnu.org/software/parallel/history.html
You can install GNU Parallel simply by:
wget http://git.savannah.gnu.org/cgit/parallel.git/plain/src/parallel
chmod 755 parallel
cp parallel sem
Watch the intro videos for GNU Parallel to l... | Why does (GNU?) parallel fail silently, and how do I fix it? |
1,386,277,472,000 |
I know that GNU Parallel buffers std/stderr because it doesn't want jobs output to be mangled, but if I run my jobs with parallel do_something ::: task_1 task_2 task_3, is there anyway for task_1's output to be displayed immediately, then after task_1 finishes, task_2's up to its current output, etc.
If Parallel canno... |
From version 20160422 you can do:
parallel -k --lb do_something ::: task_1 task_2 task_3
| GNU Parallel: immediately display job stderr/stdout one-at-a-time by jobs order |
1,386,277,472,000 |
So I have a while loop:
cat live_hosts | while read host; do \
sortstuff.sh -a "$host" > sortedstuff-"$host"; done
But this can take a long time. How would I use GNU Parallel for this while loop?
|
You don't use a while loop.
parallel "sortstuff.sh -a {} > sortedstuff-{}" <live_hosts
Note that this won't work if you have paths in your live_hosts (e.g. /some/dir/file) as it would expand to sortstuff.sh -a /some/dir/file > sortedstuff-/some/dir/file (resulting in no such file or directory); for those cases use {... | How would I use GNU Parallel for this while loop? |
1,386,277,472,000 |
% echo -e '1\n2' | parallel "bash -c 'echo :\$1' '' {}"
:1
:2
% echo -e '1\n2' | parallel bash -c 'echo :\$1' '' {}
%
I'd expect the second line to act the same.
|
parallel runs the command in a shell already (which shell it is is determined by parallel using heuristics (the intention being to invoke the same shell as the one parallel was invoked from). You can set the $PARALLEL_SHELL variable to fix the shell).
It's not a command you're passing to parallel like you would for th... | Why doesn't GNU parallel work with "bash -c"? |
1,386,277,472,000 |
I have a script that uses gnu parallel. I want to pass two parameters for each "iteration"
in serial run I have something like:
for (( i=0; i<=10; i++ ))
do
a = tmp1[$i]
b = tmp2[$i]
done
And I want to make this parallel as
func pf()
{
a=$1
b=$2
}
export -f pf
parallel --jobs 5 --linebuffer pf ::: <what to ... |
Omitting your other parallel flags just to stay focused...
parallel --link pf ::: A B ::: C D
This will run your function first with a=A, b=C followed by a=B, b=D or
a=A b=C
a=B b=D
Without --link you get full combination like this:
a=A b=C
a=A b=D
a=B b=C
a=B b=D
Update: As Ole Tange metioned in a comment [since ... | GNU parallel - two parameters from array as parameter |
1,386,277,472,000 |
I have script I'd always like to run 'x' instances in parallel.
The code looks a like that:
for A in
do
for B in
do
(script1.sh $A $B;script2.sh $A $B) &
done #B
done #A
The scripts itself run DB queries, so it would benefit from parallel running. Problem is
1) 'wait' doesn't work (because it finished all ... |
Using GNU Parallel it looks like this:
parallel script1.sh {}';' script2.sh {} ::: a b c ::: d e f
It will spawn one job per CPU.
GNU Parallel is a general parallelizer and makes is easy to run jobs in parallel on the same machine or on multiple machines you have ssh access to. It can often replace a for loop.
If you... | How to run x instances of a script parallel? |
1,386,277,472,000 |
I am having an issue trying to use parallel command on Ubuntu 10.04. I looked up the parallel documentation and few of the commands seem to run. In all cases I just get the command prompt back without any action being taken. e.g. I was trying to compress a bunch of files using bzip2
17:32 farhat HarshaNaveen$ parall... |
Your first try is closest to being correct, but why the :::? If you change ::: to --, it will do what you want.
parallel has a specific, unusual structure to its command line. In the first half, you give it the command you want to run multiple times, and the part of the command line that will be the same every time.... | Using parallel on Ubuntu |
1,386,277,472,000 |
I have a words.txt with 10000 words (one to a line). I have 5,000 documents. I want to see which documents contain which of those words (with a regex pattern around the word). I have a script.sh that greps the documents and outputs hits. I want to (1) split my input file into smaller files (2) feed each of the files t... |
You can use the split tool:
split -l 1000 words.txt words-
will split your words.txt file into files with no more than 1000 lines each named
words-aa
words-ab
words-ac
...
words-ba
words-bb
...
If you omit the prefix (words- in the above example), split uses x as the default prefix.
For using the generated files wit... | split a file, pass each piece as a param to a script, run each script in parallel |
1,386,277,472,000 |
GNU Parallel quotes replacement strings by default so that they are not expanded by the shell. But in certain cases you really want the replacement string to be interpreted by the shell.
E.g.
$ cat variables.txt
--var1 0.1 --var2 0.2
--var1 0.11 --var3 0.03
Here I want GNU Parallel to run:
myprogram --var1 0.1 --var2... |
From version 20190722 you can use uq() in a perl replacement string to make that replacement unquoted:
parallel myprogram '{=1 uq(); =}' {2} :::: variables.txt ::: My*.txt
This can not be done in earlier versions. You can, however, unquote the full command with eval. This solves the first problem, but not the second.... | How do I tell GNU Parallel to not quote the replacement string |
1,386,277,472,000 |
I'm pulling VIN specifications from the National Highway Traffic Safety Administration API for approximately 25,000,000 VIN numbers. This is a great deal of data, and as I'm not transforming the data in any way, curl seemed like a more efficient and lightweight way of accomplishing the task than Python (seeing as Pyth... |
My suspicion is that the >> is causing you contention on the file nhtsa_vin_data.csv among the curl commands that parallel is forking off to collect the API data.
I would adjust your application like this:
$ cat p.bash
#!/bin/bash
cat vins.csv | parallel --will-cite -j10% --progress --tmpdir . --files \
curl -s --... | Standard Out Append to File Size Limitations |
1,386,277,472,000 |
I have a bash program that I run via command line (Ubuntu) like this:
./extract_field.sh ABC001
where ABC001 is the field ID that I want to extract from a given shapefile.
To run this script with multiple IDs, I first save one ID per line in a list.txt file:
ABC001
ABC014
ABC213
ABC427
and then invoke the script usi... |
You can provide multiple arguments to a single command with parallel by specifying a column delimiter in your command syntax
To use your example:
parallel --colsep ' ' -a list.txt ./extractfield.sh {1} {2}
Will provide the result of
./extract_field.sh ABC001 arg2a
./extract_field.sh ABC014 arg2b
Given that your file... | Running a program with multiple arguments from list using parallel |
1,386,277,472,000 |
Some time ago I learned about the software parallel: https://forums.servethehome.com/index.php?threads/mdadm-create-raid-0-quick-format.41161/#post-389210
Now I have almost the same goal as previous, but I want to try and do it differently.
For setup I have:
Dell SFF desktop with single port SAS2 HBA
Total of 14 NetAp... |
That's because you are using /dev/sg[2-126]. Unfortunately, ranges don't handle multi-digit numbers. They are character ranges, and 126 is not a character. So while you can have [0-9], you cannot have [0-10] since that would mean "the characters from 0 to 1, and then 0". So your [2-126] actually means "the number betw... | Using parallel to sg_format 300+ drives |
1,386,277,472,000 |
What I'm really trying to do is run X number of jobs, with X amount in parallel for testing an API race condition.
I've come up with this
echo {1..10} | xargs -n1 | parallel -m 'echo "{}"';
which prints
7 8 9
10
4 5 6
1 2 3
but what I really want to see is (note order doesn't actually matter).
1
2
3
4
5
6
7
8
9
10
... |
I want 4 processes at a time, each process should process 1 record
parallel -j4 -k --no-notice 'echo "{}"' ::: {1..10}
-j4 - number of jobslots. Run up to 4 jobs in parallel
-k - keep sequence of output same as the order of input. Normally the output of a job will be printed as soon as the job completes
::: - argu... | How can I run GNU parallel in record per job, with 1 process per core |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.