Error: you did not specify -i=mi on GDB's command line! in Docker - docker

I need to run gdb inside Docker, and I have a strong preference for the interface provided by emacs.
When doing M-x gdb, I enter "docker-compose -f ~/docker-services/dev/docker-compose.yml exec dev_rhel7 bash -c "gdb -i=mi"", and then it shows me the following message.
Current directory is /home/drcoeurjoly/docker-services/dev/
Error: you did not specify -i=mi on GDB's command line!
WARNING: The MY_UID variable is not set. Defaulting to a blank string.
1-inferior-tty-set /dev/pts/3
2-gdb-set height 0
3-gdb-set non-stop 1
4-enable-pretty-printing
5-file-list-exec-source-files
6-file-list-exec-source-file
7-gdb-show prompt
8-stack-info-frame
9-thread-info
10-break-list
11-thread-info
12-break-list
=thread-group-added,id="i1"
~"GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7\n"
~"Copyright (C) 2013 Free Software Foundation, Inc.\n"
~"License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law. Type \"show copying\"\nand \"show warranty\" for details.\n"
~"This GDB was configured as \"x86_64-redhat-linux-gnu\".\nFor bug reporting instructions, please see:\n"
~"http://www.gnu.org/software/gdb/bugs/.\n"
=cmd-param-changed,param="history save",value="on"
=cmd-param-changed,param="history filename",value="/home/drcoeurjoly/dotfiles/gdb/.gdb_history"
=cmd-param-changed,param="print pretty",value="on"
=cmd-param-changed,param="print object",value="on"
=cmd-param-changed,param="print vtbl",value="on"
=cmd-param-changed,param="demangle-style",value="gnu-v3"
=cmd-param-changed,param="follow-fork-mode",value="child"
=cmd-param-changed,param="detach-on-fork",value="off"
(gdb)
1^done
(gdb)
2^done
(gdb)
3^done
(gdb)
4^done
(gdb)
5^done,files=[]
(gdb)
6^error,msg="No symbol table is loaded. Use the \"file\" command."
(gdb)
7^done,value="(gdb) "
(gdb)
8^error,msg="No registers."
(gdb)
9^done,threads=[]
(gdb)
10^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb)
11^done,threads=[]
(gdb)
12^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="7",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb)
Note that I successfully enter gdb in Docker, since GDB says:
"GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7\n"
In my host operating system (Debian):
gdb --version
outputs:
GNU gdb (Debian 8.2.1-2+b3) 8.2.1
In Debian, I execute the Docker command:
docker-compose -f ~/docker-services/dev/docker-compose.yml exec dev_rhel7 bash -c "gdb -i=mi"
and I get the machine-oriented text interface.
From the previous test I deduce that it is an issue of emacs, not Docker.
When entering the path of a binary instead of the option -i=mi, it reads the symbols just fine:
M-x gdb RETURN docker-compose -f ~/docker-services/dev/docker-compose.yml exec dev_rhel7 bash -c "gdb ~/babel_sandbox/build/foo"
which outputs:
Current directory is /home/drcoeurjoly/docker-services/dev/
Error: you did not specify -i=mi on GDB's command line!
WARNING: The MY_UID variable is not set. Defaulting to a blank string.
1-inferior-tty-set /dev/pts/3
2-gdb-set height 0
3-gdb-set non-stop 1
4-enable-pretty-printing
5-file-list-exec-source-files
6-file-list-exec-source-file
7-gdb-show prompt
8-stack-info-frame
9-thread-info
10-break-list
11-thread-info
12-break-list
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
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-redhat-linux-gnu".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /home/drcoeurjoly/babel_sandbox/build/foo...done.
(gdb) 1-inferior-tty-set /dev/pts/3
Undefined command: "1-inferior-tty-set". Try "help".
(gdb) 2-gdb-set height 0
Undefined command: "2-gdb-set". Try "help".
(gdb) 3-gdb-set non-stop 1
Undefined command: "3-gdb-set". Try "help".
(gdb) 4-enable-pretty-printing
Undefined command: "4-enable-pretty-printing". Try "help".
(gdb) 5-file-list-exec-source-files
Undefined command: "5-file-list-exec-source-files". Try "help".
(gdb) 6-file-list-exec-source-file
Undefined command: "6-file-list-exec-source-file". Try "help".
(gdb) 7-gdb-show prompt
Undefined command: "7-gdb-show". Try "help".
(gdb) 8-stack-info-frame
Undefined command: "8-stack-info-frame". Try "help".
(gdb) 9-thread-info
Undefined command: "9-thread-info". Try "help".
(gdb) 10-break-list
Undefined command: "10-break-list". Try "help".
(gdb) 11-thread-info
Undefined command: "11-thread-info". Try "help".
(gdb) 12-break-list
Undefined command: "12-break-list". Try "help".
(gdb)
I also tried putting the gdb -i=mi inside a script and calling that from emacs, to no avail. Calling directly from bash worked and not from emacs.
Relevant information:
My spacemacs config
foo program used for testing argument passing to gdb in emacs.
I don't know if the dockerfile and docker-compose yml are relevant. If so, I will create a repo.
Versions:
Host:
uname -a
Linux des26 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) x86_64 GNU/Linux
Emacs in host:
emacs --version
GNU Emacs 26.3
GDB in host:
gdb --version
GNU gdb (Debian 8.2.1-2+b3) 8.2.1
Docker in host:
docker --version
Docker version 18.09.1, build 4c52b90
Docker-compose in host:
docker-compose --version
docker-compose version 1.21.0, build unknown
Docker container:
cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
GDB in docker container:
gdb --version
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-114.el7
This issue was reported by Robert Mecklenburg here and here as early as august 2017.

Related

Dyldinfo commamd not found

mac os 10.13.4
I write the command 'dyldinfo' in shell, but is wroing
-bash: dyldinfo: command not found
hope you help me
On recent versions of macOS you can run the tool with xcrun dyldinfo (as long as you have Xcode installed)
First, make sure you have either Xcode or Command Line Tools installed.
If you have one of those, you can find dyldinfo in /Library/Developer/CommandLineTools/usr/bin.
So, to run it, type this into your bash:
/Library/Developer/CommandLineTools/usr/bin/dyldinfo
You can check the dyldinfo path using following command:
$ xcrun --sdk dyldinfo
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dyldinfo
Showing that the command dyldinfo is under the path:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/dyldinfo, which means commands like dyldinfo belong to Toolchains of Xcode. Therefore, 'dyldinfo' cannot be used as a separate shell command. Instead, you must invoke it by using xcrun <sdk>.
$ xcrun dyldinfo
Usage: dyldinfo [-arch <arch>] <options> <mach-o file>
-dylibs print dependent dylibs
-dr print dependent dylibs and show any recorded DR info
-rebase print addresses dyld will adjust if file not loaded at preferred address
-bind print addresses dyld will set based on symbolic lookups
-weak_bind print symbols which dyld must coalesce
-lazy_bind print addresses dyld will lazily set on first use
-export print addresses of all symbols this file exports
-opcodes print opcodes used to generate the rebase and binding information
-function_starts print table of function start addresses
-export_dot print a GraphViz .dot file of the exported symbols trie
-data_in_code print any data-in-code information

ejabber's erl file give error "segmentation fault: 11" while running on mac os 10.7.5

I am trying to start ejabber 16.05 server on mac os 10.7.5. while starting up, it gives error. on further investigation, I found that "erl" executor file shipped with ejabber is throwing "Segmentation Fault:11" while running independently. I firmly believe that resolving issue with "erl" file execution will solve server start up issue. can anyone please help. Below is the code from "erl" that is causing segmentation fault error
#!/bin/sh
ROOTDIR=/Applications/ejabberd-15.06
export ROOTDIR
BINDIR=$ROOTDIR/bin
export BINDIR
EMU=beam
export EMU
PROGNAME=$BINDIR/erl
export PROGNAME
PATH=$BINDIR:$PATH
export PATH
arch() {
case `uname -m` in
i[3456]86 ) echo x86 ;;
i86pc) echo x86 ;;
armv7*) echo armhf ;;
arm*l) echo armel ;;
* ) echo `uname -m | tr A-Z a-z` ;;
esac
}
os=`uname -s | tr A-Z a-z`
cpu=`arch`
ARCHDIR=${os}-${cpu}
export ARCHDIR
# Dynamic libraries
LD_LIBRARY_PATH=$ROOTDIR/lib/$ARCHDIR
export LD_LIBRARY_PATH
DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH
exec $BINDIR/erlexec ${1+"$#"}
I just see that you are using OSX 10.7. We do not test ejabberd binary installer on version of OS that are so old.
I do not even expect the binary installer to run on such an old release.
If you have to run ejabberd on that OSX version, you have to build it from source.
ejabberd source are available on official ejabberd Github.
Documentation for installation and build is here Installing ejabberd from source code.

iOS lldb function lookup

I am trying to learn how to debug iOS apps on my jailbroken iOS device using lldb.
I can't seem to figure out why lldb is not able to get functions when gdb is able to. For example, I am trying to find out what is the _mh_execute_header address.
On GDB
(gdb) info func _mh_ex*
All functions matching regular expression "_mh_ex*":
Non-debugging symbols:
0x000e5000 _mh_execute_header
On lldb
(lldb) image lookup -r -n _mh_e*
(lldb) image lookup -r -s _mh_e*
(lldb)
I did some searching around and found this site: http://versprite.com/og/ios-reverse-engineering-part-one-configuring-lldb/ and followed its instructions.
After executing the target create command:
(lldb) target create --arch arm Cood
Current executable set to '/Users/tester/Desktop/Cood' (armv7).
I can do this
(lldb) image lookup -r -n _mh_e*
(lldb) image lookup -r -s _mh_e*
1 symbols match the regular expression '_mh_e*' in /Users/tester/Desktop/Cood:
Address: Cood[0x00004000] (Cood.__TEXT + 0)
Summary: Cood`_mh_execute_header
But then I execute process continue and I get
(lldb) process continue
error: invalid process
I have no idea what is going on.
FYI, I executed the following commands on my Mac to connect to the iOS debug server (OS X Yosemite, Xcode 6.3.1, lldb-330.0.44)
(lldb) platform select remote-ios
(lldb) process connect connect://127.0.0.1:7777
(lldb) process attach -n Cood -w
Any help would be appreciated! Thank you.

Error while trying to enter sleep mode in Beagle Bone Black

While trying to enter sleep mode on beaglebone black am getting an error
When i issue the command echo -n "mem" > /sys/power/state am getting
-sh: echo: write error: No such device
The kernel version and os version is as below
root#beaglebone:~# uname -a
Linux beaglebone 3.8.13 #1 SMP Wed Sep 4 09:09:32 CEST 2013 armv7l GNU/Linux
root#beaglebone:~# lsb_release -a
Distributor ID: Angstrom
Description: Angstrom GNU/Linux v2012.12 (Core edition)
Release: v2012.12
Codename: Core edition
I was just trying to do the same thing and got the same error. Looks like the 3.8.13 kernel doesn't support suspend/sleep mode. In the link below they mention only 3.12 or higher supports that feature. (Note if you upgrade beyond 3.8.13 all the capemgr stuff works completely differently than on 3.8.13. I tried 3.18.1 and couldn't get any capes to work.)
Bug report for sleep mode

Erlang causes page faults

When I run the script described here with my user, everything is well:
lorenzo#enzo:~/erlang/pei$ time erl -noshell -smp enabled -S 4 -s fib4 main 10000000
real 0m54.952s
user 1m16.090s
sys 0m0.070s
When I run it as root, it crashed:
lorenzo#enzo:~/erlang/pei$ sudo time erl -noshell -smp enabled -S 4 -s fib4 main 10000000
[sudo] password for lorenzo:
74.68user 0.04system 0:53.56elapsed 139%CPU (0avgtext+0avgdata 66064maxresident)k
0inputs+0outputs (0major+8306minor)pagefaults 0swaps
The error is reproduceable.
My questions are:
Can someone try to explain me what is happending there?
Is it a problem with the erlang runtime or with my OS?
Can someone reproduce this error?
I am running erlang 5.7.4 on ubuntu natty with kernel
Linux enzo 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
on a Phenom X4.
Why do you think it crashed? time just shows more info when running as root. Page fault is not an error but just the way virtual memory works.
The difference between the two runs is that in the first run, you're running the shell builtin time, but in the second run, you're running whatever sudo finds in the path, which is /usr/bin/time. These two tools have different output formats.
$ type time
time is a shell keyword
$ time echo
real 0m0.000s
user 0m0.000s
sys 0m0.000s
$ type /usr/bin/time
/usr/bin/time is /usr/bin/time
$ /usr/bin/time echo
0.01user 0.00system 0:00.00elapsed 1000%CPU (0avgtext+0avgdata 2784maxresident)k
0inputs+0outputs (0major+217minor)pagefaults 0swaps

Resources