@@ -576,26 +576,61 @@ function print_info_from_core_file {
576
576
gdb --batch -ex " thread apply all bt full" -ex " quit" $executable_name $core_file_name
577
577
}
578
578
579
- function copy_core_file_to_temp_location {
579
+ function download_dumpling_script {
580
+ echo " Downloading latest version of dumpling script."
581
+ wget " https://raw.githubusercontent.com/Microsoft/dotnet-reliability/master/src/triage.python/dumpling.py"
582
+
583
+ local dumpling_script=" dumpling.py"
584
+ chmod +x $dumpling_script
585
+ }
586
+
587
+ function upload_core_file_to_dumpling {
588
+ local core_file_name=$1
589
+ local dumpling_script=" dumpling.py"
590
+
591
+ if [ ! -x $dumpling_script ]; then
592
+ download_dumpling_script
593
+ fi
594
+
595
+ if [ ! -x $dumpling_script ]; then
596
+ echo " Failed to download dumpling script. Dump cannot be uploaded."
597
+ return
598
+ fi
599
+
600
+ echo " Uploading $core_file_name to dumpling service."
601
+
602
+ local paths_to_add=" "
603
+ if [ -d " $coreClrBinDir " ]; then
604
+ echo " Uploading CoreCLR binaries with dump."
605
+ paths_to_add=$coreClrBinDir
606
+ fi
607
+
608
+ # The output from this will include a unique ID for this dump.
609
+ ./$dumpling_script " --corefile" " $core_file_name " " upload" " --addpaths" $paths_to_add
610
+ }
611
+
612
+ function preserve_core_file {
580
613
local core_file_name=$1
581
614
local storage_location=" /tmp/coredumps_coreclr"
582
615
583
616
# Create the directory (this shouldn't fail even if it already exists).
584
617
mkdir -p $storage_location
585
618
586
- # Only copy the file over if the directory is empty. Otherwise, do nothing.
619
+ # Only preserve the dump if the directory is empty. Otherwise, do nothing.
620
+ # This is a way to prevent us from storing/uploading too many dumps.
587
621
if [ ! " $( ls -A $storage_location ) " ]; then
588
622
echo " Copying core file $core_file_name to $storage_location "
589
623
cp $core_file_name $storage_location
624
+
625
+ upload_core_file_to_dumpling $core_file_name
590
626
fi
591
627
}
592
628
593
629
function inspect_and_delete_core_files {
594
630
# This function prints some basic information from core files in the current
595
631
# directory and deletes them immediately. Based on the state of the system, it may
596
- # also store one core file in a non-transient directory so that it's available
597
- # after the run is complete even if the directory for the run is deleted
598
- # (see copy_core_file_to_temp_location).
632
+ # also upload a core file to the dumpling service.
633
+ # (see preserve_core_file).
599
634
600
635
# Depending on distro/configuration, the core files may either be named "core"
601
636
# or "core.<PID>" by default. We will read /proc/sys/kernel/core_uses_pid to
@@ -609,11 +644,11 @@ function inspect_and_delete_core_files {
609
644
# We don't know what the PID of the process was, so let's look at all core
610
645
# files whose name matches core.NUMBER
611
646
for f in core.* ; do
612
- [[ $f =~ core.[0-9]+ ]] && print_info_from_core_file " $f " $CORE_ROOT /" corerun" && copy_core_file_to_temp_location " $f " && rm " $f "
647
+ [[ $f =~ core.[0-9]+ ]] && print_info_from_core_file " $f " $CORE_ROOT /" corerun" && preserve_core_file " $f " && rm " $f "
613
648
done
614
649
elif [ -f core ]; then
615
650
print_info_from_core_file " core" $CORE_ROOT /" corerun"
616
- copy_core_file_to_temp_location " core"
651
+ preserve_core_file " core"
617
652
rm " core"
618
653
fi
619
654
}
0 commit comments