This is a follow up on “Building GDB From Source”, and uses the vagrant environment described in the previous post. It covers doing a bunch of basic things, which are largely independent of each other.
Generating a Patch:
Patches are git diffs and can be generated:
- From the last commit:
git format-patch -1 HEAD
- From unstaged changes
git diff > changes.patch
Generating a ChangeLog:
Use the mklog
command from the GDB wiki.
1) Download the file or run
wget -O mklog https://gcc.gnu.org/viewcvs/gcc/trunk/contrib/mklog?view=co
2) Give executable priviledges
chmod +x mklog
3) Run on the PATCH file:
./mklog changes.patch > ChangeLog
4) Explain the ChangeLog
emacs ChangeLog
Testing a Patch:
This part is based off of the “Working on GDB” approach from gbenson.net.
Find the latest branch here, i.e. gdb-8.2-branch
and then check it out (or just use HEAD
):
git checkout gdb-8.2-branch
1) Build and then run the testsuite without any changes:
mkdir 8.2 && cd 8.2
../configure --enable-targets=all --with-expat
make
make check -j4 >& ../8.2.log
cd ..
2) Build and then run the testsuite with the patch:
git apply changes.patch
mkdir 8.2-changes && cd 8.2-changes
../configure --enable-targets=all --with-expat
make
make check -j4 >& ../8.2-changes.log
cd ..
3) Diff the file:
diff 8.2.log 8.2-changes.log
Exporting a Patch from Vagrant:
1) Run vagrant ssh-config
and find the values Port
and Identity File
in the output.
2) Copy the desired file from vagrant to the host machine:
scp -P {Port} -i {IdentityFile} vagrant@127.0.0.1:~/gdb/changes.patch .
Expanding a Vagrant Box:
In order to accomodate the size of multiple GDB installations, the default Debian box needs to be made bigger, since it only has about 8GB of space. This involves two parts: expanding the size of the VirtualBox disk partition and expanding the file system.
1) Expanding the VirtualBox disk size:
First, convert the stretch.vmdk
disk file to a stretch.vdi
one and
make it bigger and then covert it back. It will be located within the
VirtualBox VMs
folder. This approach is common [1] [2].
On Unix:
vagrant halt
cd ~/VirtualBox\ VMs/debian_default_*
VBoxManage clonehd stretch.vmdk stretch.vdi --format vdi
VBoxManage modifyhd stretch.vdi --resize 50000
rm -f *.vmdk
VBoxManage clonehd stretch.vdi stretch.vmdk --format vmdk
rm -f *.vdi
On Windows: (Replace USERNAME
)
vagrant halt
cd "C:\Users\USERNAME\VirtualBox VMs\debian_default_*"
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonehd stretch.vmdk stretch.vdi --format vdi
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" modifyhd stretch.vdi --resize 50000
del *.vmdk
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonehd stretch.vdi stretch.vmdk --format vmdk
del *.vdi
This resizes the disk size to 50GB. 20GB would also work (use --resize 20000
).
Return to the vagrant directory. Then run:
vagrant up
vagrant ssh
2) Expand the primary partition size:
Check the file system:
df -h
This should show that /dev/sda1 has 8.7G capacity mounted on /
. If
there is a different disk instead, then use that one going forward.
Next print out the partitions:
sudo fdisk -l
There should be three: Linux, Extended, and Linux swap / Solaris.
Then run fdisk and the following commands (not the comments):
sudo fdisk /dev/sda
d # Delete all partitions
1
d
2
w # Write changes
Create a new primary partition:
sudo fdisk /dev/sda
n # New partition
p # Primary partition
1 # At /dev/sda1
<enter> # Default start location (at 2048)
+45G # Partition size
No # Don't remove the ext4 signature
w # Write changes
Create swap partition:
sudo fdisk /dev/sda
n # New partition
e # Extend partition
4 # At /dev/sda4
<enter> # Default start location
<enter> # Partition size maximum
w # Write changes
Change partition type to swap:
sudo fdisk /dev/sda
t # Chang Partition Type
4 # At /dev/sda4
82 # Linux swap / Solaris
w # Write changes
Restart the vagrant box (Note that it may take a while this time with some error messages):
logout
vagrant halt
vagrant up
vagrant ssh
3) Resize the file system to take up the whole partition:
sudo resize2fs /dev/sda1
sudo mke2fs -t ext4 /dev/sda4
sudo tune2fs -U random /dev/sda4
y
sudo blkid
Finally copy the UUID of /dev/sda4 and write it in the file below,
replacing the UUID under the # swap was on /dev/vda5 during installation
comment (and change the comment):
emacs /etc/fstab
Then restart with:
logout
vagrant halt
vagrant up
vagrant ssh
And running: df -h
should show the new expanded size.