In the Oracle VirtualBox, to add a shared folder to a Linux guest, open Devices>Shared Folders... and click Add Shared Folder (a tiny "plus" icon on the right). Then fill folder path and folder name.
In Linux, do the mount by the following commands:
> sudo mkdir /home/shared # creating mount point
> sudo mount -t vboxsf VShared /home/shared # use previously filled folder name
After every reboots the mount command is needed to repeat.
To do it automatically, just add the following lines to fstab.
> sudo echo "VShared /home/shared vboxsf rw 0 0" >> /etc/fstab
Tuesday, April 24, 2012
Friday, April 20, 2012
find | xargs with spaces in filenames
The following command is one of the simplest way to find a text in the files.
find * | xargs grep "text"
but if the file name contains a space then the xargs command split it and transfer spited items as a separate files to the grep, and an error occurs:
grep: "a part of file name": No such file or directory
To overcome this issue the find has an -print0 option, which separates file names with ASCII NUL instead of new line. And the -0 option will signal the xargs to use NUL as a separator instead of blank spaces.
find * -print0 | xargs -0 grep "text"
find * | xargs grep "text"
but if the file name contains a space then the xargs command split it and transfer spited items as a separate files to the grep, and an error occurs:
grep: "a part of file name": No such file or directory
To overcome this issue the find has an -print0 option, which separates file names with ASCII NUL instead of new line. And the -0 option will signal the xargs to use NUL as a separator instead of blank spaces.
find * -print0 | xargs -0 grep "text"
Tuesday, April 3, 2012
Compile gdb for embedded devices
To debug a program on embedded devices with limited resources(memory, CPU) the gdbserver is used. The gdbserver is running on the embedded device, while the gdb is running on a regular PC and connect with gdbserver via network. The first step is to compile gdb for embedded device(platform). The following steps are for platform with ARM CPU.
Get the sources from official site: http://www.gnu.org/software/gdb/download/
Compile gdb
>tar -zxf gdb-7.4.tar.gz #extract the sources
>cd gdb-7.4
> ./configure --prefix=/home/programs/gdb/ --build=x86 --host=x86 --target=arm-linux
"--prefix" - where to install the program
"--build" - specify which platform is used for compilation.
"--host" - specify which platform is used for run gdb.
"--target" - specify which platform is used for run the debugging program.
>make
>make install
Compile gdbserver(the gcc compiler for arm-linux is necessary)
>tar -zxf gdb-7.4.tar.gz #extract the sources into new folder
>cd gdb/gdbserver
>./configure --host=arm-linux
>make
during the compilation linux-arm-low.c:642: error: `PTRACE_GETSIGINFO' undeclared (first use in this function) error occurs. Seems a include is missing, but by adding the following line before the error line, the problem will be solved.
#define PTRACE_GETSIGINFO 0x4202
>make
Copy the gdbserver executable from current directory to the target device and run:
>gdbserver :<port> <program>
From the PC run gdb and connect to gdbserver vi the network:
(gdb)>target remote ip:port
Now the program can be debuged with usual gdb commands.
Get the sources from official site: http://www.gnu.org/software/gdb/download/
Compile gdb
>tar -zxf gdb-7.4.tar.gz #extract the sources
>cd gdb-7.4
> ./configure --prefix=/home/programs/gdb/ --build=x86 --host=x86 --target=arm-linux
"--prefix" - where to install the program
"--build" - specify which platform is used for compilation.
"--host" - specify which platform is used for run gdb.
"--target" - specify which platform is used for run the debugging program.
>make
>make install
Compile gdbserver(the gcc compiler for arm-linux is necessary)
>tar -zxf gdb-7.4.tar.gz #extract the sources into new folder
>cd gdb/gdbserver
>./configure --host=arm-linux
>make
during the compilation linux-arm-low.c:642: error: `PTRACE_GETSIGINFO' undeclared (first use in this function) error occurs. Seems a include is missing, but by adding the following line before the error line, the problem will be solved.
#define PTRACE_GETSIGINFO 0x4202
>make
Copy the gdbserver executable from current directory to the target device and run:
>gdbserver :<port> <program>
From the PC run gdb and connect to gdbserver vi the network:
(gdb)>target remote ip:port
Now the program can be debuged with usual gdb commands.
Subscribe to:
Posts (Atom)