diff --git a/build_debian.sh b/build_debian.sh index f9236bff36..a21021ec68 100755 --- a/build_debian.sh +++ b/build_debian.sh @@ -422,6 +422,28 @@ fi sudo sed -i 's/EBTABLES_LOAD_ON_START="no"/EBTABLES_LOAD_ON_START="yes"/g' ${FILESYSTEM_ROOT}/etc/default/ebtables sudo cp files/image_config/ebtables/ebtables.filter ${FILESYSTEM_ROOT}/etc +## Debug Image specific changes +## Update motd for debug image +if [ "$DEBUG_IMG" == "y" ] +then + sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "echo '**************' >> /etc/motd" + sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "echo 'Running DEBUG image' >> /etc/motd" + sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "echo '**************' >> /etc/motd" + sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "echo '/src has the sources' >> /etc/motd" + sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "echo '/src is mounted in each docker' >> /etc/motd" + sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "echo '/debug is created for core files or temp files' >> /etc/motd" + sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "echo 'Create a subdir under /debug to upload your files' >> /etc/motd" + sudo LANG=C chroot $FILESYSTEM_ROOT /bin/bash -c "echo '/debug is mounted in each docker' >> /etc/motd" + + sudo mkdir -p $FILESYSTEM_ROOT/src + pushd src + ../scripts/dbg_files.sh | sudo tar -cvzf ../$FILESYSTEM_ROOT/src/sonic_src.tar.gz -T - + popd + + sudo mkdir -p $FILESYSTEM_ROOT/debug + +fi + ## Remove gcc and python dev pkgs sudo LANG=C DEBIAN_FRONTEND=noninteractive chroot $FILESYSTEM_ROOT apt-get -y remove gcc libpython2.7-dev diff --git a/dockers/docker-base-stretch/Dockerfile.j2 b/dockers/docker-base-stretch/Dockerfile.j2 index fedc0254ba..8b1d0adcfe 100644 --- a/dockers/docker-base-stretch/Dockerfile.j2 +++ b/dockers/docker-base-stretch/Dockerfile.j2 @@ -53,13 +53,6 @@ RUN apt-get -y purge \ {{ install_debian_packages(docker_base_stretch_debs.split(' ')) }} {%- endif %} -{% if docker_base_stretch_dbgs.strip() -%} -# Install common debug-packages -RUN apt-get -y install docker_base_stretch_dbgs.split(' ') | join(' ') -{% else %} -RUN ln /usr/bin/vim.tiny /usr/bin/vim -{%- endif %} - # Clean up apt # Remove /var/lib/apt/lists/*, could be obsoleted for derived images RUN apt-get clean -y && \ diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index f6f46aa49a..9966728988 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -170,6 +170,9 @@ start() { # TODO: Mellanox will remove the --tmpfs exception after SDK socket path changed in new SDK version {%- endif %} docker create {{docker_image_run_opt}} \ +{%- if install_debug_image == "y" %} + -v /src:/src:ro -v /debug:/debug:rw \ +{%- endif %} {%- if '--log-driver=json-file' in docker_image_run_opt or '--log-driver' not in docker_image_run_opt %} --log-opt max-size=2M --log-opt max-file=5 \ {%- endif %} diff --git a/rules/docker-base-stretch.mk b/rules/docker-base-stretch.mk index a2495ed316..55b7fd9f86 100644 --- a/rules/docker-base-stretch.mk +++ b/rules/docker-base-stretch.mk @@ -12,9 +12,6 @@ OPENSSH = openssh-client SSHPASS = sshpass STRACE = strace $(DOCKER_BASE_STRETCH)_DBG_IMAGE_PACKAGES += $(GDB) $(GDBSERVER) $(VIM) $(OPENSSH) $(SSHPASS) $(STRACE) -ifeq ($(INSTALL_DEBUG_TOOLS),y) -$(DOCKER_BASE_STRETCH)_DBG_PACKAGES += $($(DOCKER_BASE_STRETCH)_DBG_IMAGE_PACKAGES) -endif SONIC_DOCKER_IMAGES += $(DOCKER_BASE_STRETCH) SONIC_STRETCH_DOCKERS += $(DOCKER_BASE_STRETCH) diff --git a/rules/docker-database.mk b/rules/docker-database.mk index 5cfaabb28d..f148b21775 100644 --- a/rules/docker-database.mk +++ b/rules/docker-database.mk @@ -8,6 +8,7 @@ $(DOCKER_DATABASE)_PATH = $(DOCKERS_PATH)/$(DOCKER_DATABASE_STEM) $(DOCKER_DATABASE)_DEPENDS += $(REDIS_TOOLS) $(REDIS_SERVER) $(DOCKER_DATABASE)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) +$(DOCKER_DATABASE)_DBG_DEPENDS += $(REDIS_SERVER_DBG) $(DOCKER_DATABASE)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) diff --git a/rules/docker-dhcp-relay.mk b/rules/docker-dhcp-relay.mk index f2432cdc00..6fad19cc19 100644 --- a/rules/docker-dhcp-relay.mk +++ b/rules/docker-dhcp-relay.mk @@ -8,6 +8,8 @@ $(DOCKER_DHCP_RELAY)_PATH = $(DOCKERS_PATH)/$(DOCKER_DHCP_RELAY_STEM) $(DOCKER_DHCP_RELAY)_DEPENDS += $(ISC_DHCP_RELAY) $(REDIS_TOOLS) $(DOCKER_DHCP_RELAY)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) +$(DOCKER_DHCP_RELAY)_DBG_DEPENDS += $(ISC_DHCP_RELAY_DBG) + $(DOCKER_DHCP_RELAY)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) $(DOCKER_DHCP_RELAY)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_STRETCH) diff --git a/rules/docker-fpm-frr.mk b/rules/docker-fpm-frr.mk index d10ac325f2..5914e8b799 100644 --- a/rules/docker-fpm-frr.mk +++ b/rules/docker-fpm-frr.mk @@ -1,10 +1,25 @@ # docker image for fpm-frr -DOCKER_FPM_FRR = docker-fpm-frr.gz -$(DOCKER_FPM_FRR)_PATH = $(DOCKERS_PATH)/docker-fpm-frr +DOCKER_FPM_FRR_STEM = docker-fpm-frr +DOCKER_FPM_FRR = $(DOCKER_FPM_FRR_STEM).gz +DOCKER_FPM_FRR_DBG = $(DOCKER_FPM_FRR_STEM)-$(DBG_IMAGE_MARK).gz + +$(DOCKER_FPM_FRR)_PATH = $(DOCKERS_PATH)/$(DOCKER_FPM_FRR_STEM) + $(DOCKER_FPM_FRR)_DEPENDS += $(FRR) $(FRR_SNMP) $(SWSS) $(LIBYANG) +$(DOCKER_FPM_FRR)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) +$(DOCKER_FPM_FRR)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) \ + $(FRR_DBG) $(FRR_SNMP_DBG) $(LIBYANG_DBG) + +$(DOCKER_FPM_FRR)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) + $(DOCKER_FPM_FRR)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH) + SONIC_DOCKER_IMAGES += $(DOCKER_FPM_FRR) +SONIC_STRETCH_DOCKERS += $(DOCKER_FPM_FRR) + +SONIC_DOCKER_DBG_IMAGES += $(DOCKER_FPM_FRR_DBG) +SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_FPM_FRR_DBG) $(DOCKER_FPM_FRR)_CONTAINER_NAME = bgp $(DOCKER_FPM_FRR)_RUN_OPT += --net=host --privileged -t @@ -13,4 +28,3 @@ $(DOCKER_FPM_FRR)_RUN_OPT += -v /etc/sonic/frr:/etc/frr:rw $(DOCKER_FPM_FRR)_BASE_IMAGE_FILES += vtysh:/usr/bin/vtysh -SONIC_STRETCH_DOCKERS += $(DOCKER_FPM_FRR) diff --git a/rules/docker-fpm.mk b/rules/docker-fpm.mk index b38ad99356..72d89999c4 100644 --- a/rules/docker-fpm.mk +++ b/rules/docker-fpm.mk @@ -4,6 +4,7 @@ ifeq ($(SONIC_ROUTING_STACK), quagga) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_FPM_QUAGGA) else ifeq ($(SONIC_ROUTING_STACK), frr) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_FPM_FRR) +SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_FPM_FRR_DBG) else SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_FPM_GOBGP) endif diff --git a/rules/docker-lldp-sv2.mk b/rules/docker-lldp-sv2.mk index bb331917d6..a4bb04047b 100644 --- a/rules/docker-lldp-sv2.mk +++ b/rules/docker-lldp-sv2.mk @@ -1,14 +1,29 @@ # docker image for lldp agent -DOCKER_LLDP_SV2 = docker-lldp-sv2.gz +DOCKER_LLDP_SV2_STEM = docker-lldp-sv2 +DOCKER_LLDP_SV2 = $(DOCKER_LLDP_SV2_STEM).gz +DOCKER_LLDP_SV2_DBG = $(DOCKER_LLDP_SV2_STEM)-$(DBG_IMAGE_MARK).gz + $(DOCKER_LLDP_SV2)_PATH = $(DOCKERS_PATH)/docker-lldp-sv2 + $(DOCKER_LLDP_SV2)_DEPENDS += $(LLDPD) $(LIBSWSSCOMMON) $(PYTHON_SWSSCOMMON) + +$(DOCKER_LLDP_SV2)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) +$(DOCKER_LLDP_SV2)_DBG_DEPENDS += $(LLDPD_DBG) $(LIBSWSSCOMMON_DBG) + +$(DOCKER_LLDP_SV2)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) + $(DOCKER_LLDP_SV2)_PYTHON_WHEELS += $(DBSYNCD_PY2) $(DOCKER_LLDP_SV2)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH) + SONIC_DOCKER_IMAGES += $(DOCKER_LLDP_SV2) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_LLDP_SV2) SONIC_STRETCH_DOCKERS += $(DOCKER_LLDP_SV2) +SONIC_DOCKER_DBG_IMAGES += $(DOCKER_LLDP_SV2_DBG) +SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_LLDP_SV2_DBG) +SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_LLDP_SV2_DBG) + $(DOCKER_LLDP_SV2)_CONTAINER_NAME = lldp $(DOCKER_LLDP_SV2)_RUN_OPT += --net=host --privileged -t $(DOCKER_LLDP_SV2)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro diff --git a/rules/docker-platform-monitor.mk b/rules/docker-platform-monitor.mk index 7f1f4022e4..217c12178a 100644 --- a/rules/docker-platform-monitor.mk +++ b/rules/docker-platform-monitor.mk @@ -14,7 +14,9 @@ $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_PLATFORM_API_PY2) $(DOCKER_PLATFORM_MONITOR)_PYTHON_WHEELS += $(SONIC_DAEMON_BASE_PY2) $(DOCKER_PLATFORM_MONITOR)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) -$(DOCKER_PLATFORM_MONITOR)_DBG_DEPENDS += $(LIBSWSSCOMMON_DBG) +$(DOCKER_PLATFORM_MONITOR)_DBG_DEPENDS += $(LIBSWSSCOMMON_DBG) $(LIBSENSORS_DBG) +$(DOCKER_PLATFORM_MONITOR)_DBG_DEPENDS += $(LM_SENSORS_DBG) $(SENSORD_DBG) + $(DOCKER_PLATFORM_MONITOR)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) $(DOCKER_PLATFORM_MONITOR)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_STRETCH) diff --git a/rules/docker-router-advertiser.mk b/rules/docker-router-advertiser.mk index 29fa46719f..93dc028558 100644 --- a/rules/docker-router-advertiser.mk +++ b/rules/docker-router-advertiser.mk @@ -8,6 +8,8 @@ $(DOCKER_ROUTER_ADVERTISER)_PATH = $(DOCKERS_PATH)/$(DOCKER_ROUTER_ADVERTISER_ST $(DOCKER_ROUTER_ADVERTISER)_DEPENDS += $(RADVD) $(REDIS_TOOLS) $(DOCKER_ROUTER_ADVERTISER)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) +$(DOCKER_ROUTER_ADVERTISER)_DBG_DEPENDS += $(RADVD_DBG) + $(DOCKER_ROUTER_ADVERTISER)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) $(DOCKER_ROUTER_ADVERTISER)_LOAD_DOCKERS = $(DOCKER_CONFIG_ENGINE_STRETCH) diff --git a/rules/docker-snmp-sv2.mk b/rules/docker-snmp-sv2.mk index 37a640284d..2a533b4361 100644 --- a/rules/docker-snmp-sv2.mk +++ b/rules/docker-snmp-sv2.mk @@ -1,15 +1,30 @@ # docker image for snmp agent -DOCKER_SNMP_SV2 = docker-snmp-sv2.gz +DOCKER_SNMP_SV2_STEM = docker-snmp-sv2 +DOCKER_SNMP_SV2 = $(DOCKER_SNMP_SV2_STEM).gz +DOCKER_SNMP_SV2_DBG = $(DOCKER_SNMP_SV2_STEM)-$(DBG_IMAGE_MARK).gz + $(DOCKER_SNMP_SV2)_PATH = $(DOCKERS_PATH)/docker-snmp-sv2 + ## TODO: remove LIBPY3_DEV if we can get pip3 directly $(DOCKER_SNMP_SV2)_DEPENDS += $(SNMP) $(SNMPD) $(PY3) $(LIBPY3_DEV) + +$(DOCKER_SNMP_SV2)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) +$(DOCKER_SNMP_SV2)_DBG_DEPENDS += $(SNMP_DBG) $(SNMPD_DBG) $(LIBSNMP_DBG) + +$(DOCKER_SNMP_SV2)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) + $(DOCKER_SNMP_SV2)_PYTHON_WHEELS += $(SONIC_PLATFORM_COMMON_PY3) $(SWSSSDK_PY3) $(ASYNCSNMP_PY3) $(DOCKER_SNMP_SV2)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH) + SONIC_DOCKER_IMAGES += $(DOCKER_SNMP_SV2) SONIC_INSTALL_DOCKER_IMAGES += $(DOCKER_SNMP_SV2) SONIC_STRETCH_DOCKERS += $(DOCKER_SNMP_SV2) +SONIC_DOCKER_DBG_IMAGES += $(DOCKER_SNMP_SV2_DBG) +SONIC_INSTALL_DOCKER_DBG_IMAGES += $(DOCKER_SNMP_SV2_DBG) +SONIC_STRETCH_DBG_DOCKERS += $(DOCKER_SNMP_SV2_DBG) + $(DOCKER_SNMP_SV2)_CONTAINER_NAME = snmp $(DOCKER_SNMP_SV2)_RUN_OPT += --net=host --privileged -t $(DOCKER_SNMP_SV2)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro diff --git a/rules/docker-teamd.mk b/rules/docker-teamd.mk index f3a371f601..a697ce6b88 100644 --- a/rules/docker-teamd.mk +++ b/rules/docker-teamd.mk @@ -9,6 +9,8 @@ $(DOCKER_TEAMD)_PATH = $(DOCKERS_PATH)/$(DOCKER_TEAMD_STEM) $(DOCKER_TEAMD)_DEPENDS += $(SWSS) $(LIBTEAMDCT) $(LIBTEAM_UTILS) $(REDIS_TOOLS) $(DOCKER_TEAMD)_DBG_DEPENDS = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_DEPENDS) $(DOCKER_TEAMD)_DBG_DEPENDS += $(SWSS_DBG) $(LIBSWSSCOMMON_DBG) +$(DOCKER_TEAMD)_DBG_DEPENDS += $(LIBTEAMDCT_DBG) $(LIBTEAM_UTILS_DBG) + $(DOCKER_TEAMD)_DBG_IMAGE_PACKAGES = $($(DOCKER_CONFIG_ENGINE_STRETCH)_DBG_IMAGE_PACKAGES) $(DOCKER_TEAMD)_LOAD_DOCKERS += $(DOCKER_CONFIG_ENGINE_STRETCH) diff --git a/rules/frr.mk b/rules/frr.mk index 52dfbe13ec..9420cb2135 100644 --- a/rules/frr.mk +++ b/rules/frr.mk @@ -25,3 +25,8 @@ FRR_SNMP_DBG = frr-snmp-dbgsym_$(FRR_VERSION)-sonic-$(FRR_SUBVERSION)_amd64.deb $(eval $(call add_derived_package,$(FRR),$(FRR_SNMP_DBG))) export FRR FRR_PYTHONTOOLS FRR_DBG FRR_SNMP FRR_SNMP_DBG + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += sonic-frr diff --git a/rules/isc-dhcp.mk b/rules/isc-dhcp.mk index 67d7ed7564..316697b51d 100644 --- a/rules/isc-dhcp.mk +++ b/rules/isc-dhcp.mk @@ -9,3 +9,6 @@ $(ISC_DHCP_RELAY)_SRC_PATH = $(SRC_PATH)/isc-dhcp SONIC_MAKE_DEBS += $(ISC_DHCP_RELAY) SONIC_STRETCH_DEBS += $(ISC_DHCP_RELAY) + +ISC_DHCP_RELAY_DBG = isc-dhcp-relay-dbgsym_$(ISC_DHCP_VERSION)_amd64.deb +$(eval $(call add_derived_package,$(ISC_DHCP_RELAY),$(ISC_DHCP_RELAY_DBG))) diff --git a/rules/libnl3.mk b/rules/libnl3.mk index 30e27c5c51..dfe51093b0 100644 --- a/rules/libnl3.mk +++ b/rules/libnl3.mk @@ -46,3 +46,8 @@ $(eval $(call add_derived_package,$(LIBNL3),$(LIBNL_CLI))) LIBNL_CLI_DEV = libnl-cli-3-dev_$(LIBNL3_VERSION)_amd64.deb $(LIBNL_CLI_DEV)_DEPENDS += $(LIBNL_CLI) $(LIBNL_GENL3_DEV) $(LIBNL_NF3_DEV) $(LIBNL_ROUTE3_DEV) $(eval $(call add_derived_package,$(LIBNL3),$(LIBNL_CLI_DEV))) + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += libnl3 diff --git a/rules/libteam.mk b/rules/libteam.mk index d781db8ba9..566003b683 100644 --- a/rules/libteam.mk +++ b/rules/libteam.mk @@ -9,6 +9,9 @@ $(LIBTEAM)_SRC_PATH = $(SRC_PATH)/libteam $(LIBTEAM)_DEPENDS += $(LIBNL_GENL3_DEV) $(LIBNL_CLI_DEV) SONIC_MAKE_DEBS += $(LIBTEAM) +LIBTEAM_DBG = libteam5-dbgsym_$(LIBTEAM_VERSION)_amd64.deb +$(eval $(call add_derived_package,$(LIBTEAM),$(LIBTEAM_DBG))) + LIBTEAM_DEV = libteam-dev_$(LIBTEAM_VERSION)_amd64.deb $(LIBTEAM_DEV)_DEPENDS += $(LIBTEAMDCT) $(eval $(call add_derived_package,$(LIBTEAM),$(LIBTEAM_DEV))) @@ -16,6 +19,17 @@ $(eval $(call add_derived_package,$(LIBTEAM),$(LIBTEAM_DEV))) LIBTEAMDCT = libteamdctl0_$(LIBTEAM_VERSION)_amd64.deb $(eval $(call add_derived_package,$(LIBTEAM),$(LIBTEAMDCT))) +LIBTEAMDCT_DBG = libteamdctl0-dbgsym_$(LIBTEAM_VERSION)_amd64.deb +$(eval $(call add_derived_package,$(LIBTEAMDCT),$(LIBTEAMDCT_DBG))) + LIBTEAM_UTILS = libteam-utils_$(LIBTEAM_VERSION)_amd64.deb $(LIBTEAM_UTILS)_DEPENDS += $(LIBTEAMDCT) $(eval $(call add_derived_package,$(LIBTEAM),$(LIBTEAM_UTILS))) + +LIBTEAM_UTILS_DBG = libteam-utils-dbgsym_$(LIBTEAM_VERSION)_amd64.deb +$(eval $(call add_derived_package,$(LIBTEAM_UTILS),$(LIBTEAM_UTILS_DBG))) + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += libteam diff --git a/rules/libyang.mk b/rules/libyang.mk index e2dabdf304..fa2307c2a7 100644 --- a/rules/libyang.mk +++ b/rules/libyang.mk @@ -17,4 +17,7 @@ SONIC_STRETCH_DEBS += $(LIBYANG) LIBYANG_DEV = libyang-dev_$(LIBYANG_VERSION)-$(LIBYANG_SUBVERSION)_amd64.deb $(eval $(call add_derived_package,$(LIBYANG),$(LIBYANG_DEV))) -export LIBYANG LIBYANG_DEV +LIBYANG_DBG = libyang$(LIBYANG_VERSION_BASE)-dbgsym_$(LIBYANG_VERSION)-$(LIBYANG_SUBVERSION)_amd64.deb +$(eval $(call add_derived_package,$(LIBYANG),$(LIBYANG_DBG))) + +export LIBYANG LIBYANG_DEV LIBYANG_DBG diff --git a/rules/lldpd.mk b/rules/lldpd.mk index ff7f8889ad..839ea2156d 100644 --- a/rules/lldpd.mk +++ b/rules/lldpd.mk @@ -13,8 +13,17 @@ SONIC_MAKE_DEBS += $(LLDPD) LIBLLDPCTL = liblldpctl-dev_$(LLDPD_VERSION_FULL)_amd64.deb $(eval $(call add_derived_package,$(LLDPD),$(LIBLLDPCTL))) +LLDPD_DBG = lldpd-dbgsym_$(LLDPD_VERSION_FULL)_amd64.deb +$(eval $(call add_derived_package,$(LLDPD),$(LLDPD_DBG))) + # Export these variables so they can be used in a sub-make export LLDPD_VERSION export LLDPD_VERSION_FULL export LLDPD export LIBLLDPCTL +export LLDPD_DBG + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += lldpd diff --git a/rules/lm-sensors.mk b/rules/lm-sensors.mk index b158d9b501..ba1aeb4ecc 100644 --- a/rules/lm-sensors.mk +++ b/rules/lm-sensors.mk @@ -6,21 +6,38 @@ LM_SENSORS_VERSION_FULL=$(LM_SENSORS_VERSION)-4 LM_SENSORS = lm-sensors_$(LM_SENSORS_VERSION_FULL)_amd64.deb $(LM_SENSORS)_SRC_PATH = $(SRC_PATH)/lm-sensors +LM_SENSORS_DBG = lm-sensors-dbgsym_$(LM_SENSORS_VERSION_FULL)_amd64.deb +$(eval $(call add_derived_package,$(LM_SENSORS),$(LM_SENSORS_DBG))) + FANCONTROL = fancontrol_$(LM_SENSORS_VERSION_FULL)_all.deb $(eval $(call add_derived_package,$(LM_SENSORS),$(FANCONTROL))) LIBSENSORS = libsensors4_$(LM_SENSORS_VERSION_FULL)_amd64.deb $(eval $(call add_derived_package,$(LM_SENSORS),$(LIBSENSORS))) +LIBSENSORS_DBG = libsensors4-dbgsym_$(LM_SENSORS_VERSION_FULL)_amd64.deb +$(eval $(call add_derived_package,$(LIBSENSORS),$(LIBSENSORS_DBG))) + SENSORD = sensord_$(LM_SENSORS_VERSION_FULL)_amd64.deb $(eval $(call add_derived_package,$(LM_SENSORS),$(SENSORD))) $(SENSORD)_DEPENDS += $(LIBSENSORS) $(LM_SENSORS) +SENSORD_DBG = sensord-dbgsym_$(LM_SENSORS_VERSION_FULL)_amd64.deb +$(eval $(call add_derived_package,$(SENSORD),$(SENSORD_DBG))) + SONIC_MAKE_DEBS += $(LM_SENSORS) +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += lm-sensors + export LM_SENSORS export FANCONTROL export LIBSENSORS export SENSORD export LM_SENSORS_VERSION export LM_SENSORS_VERSION_FULL +export LM_SENSORS_DBG +export LIBSENSORS_DBG +export SENSORD_DBG diff --git a/rules/radvd.mk b/rules/radvd.mk index f43a2ce518..1673369dd4 100644 --- a/rules/radvd.mk +++ b/rules/radvd.mk @@ -8,3 +8,11 @@ RADVD = radvd_$(RADVD_VERSION)_amd64.deb $(RADVD)_SRC_PATH = $(SRC_PATH)/radvd SONIC_MAKE_DEBS += $(RADVD) SONIC_STRETCH_DEBS += $(RADVD) + +RADVD_DBG = radvd-dbgsym_$(RADVD_VERSION)_amd64.deb +$(eval $(call add_derived_package,$(RADVD),$(RADVD_DBG))) + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += radvd diff --git a/rules/redis.mk b/rules/redis.mk index 150123e2c1..557453574d 100644 --- a/rules/redis.mk +++ b/rules/redis.mk @@ -9,8 +9,16 @@ SONIC_MAKE_DEBS += $(REDIS_TOOLS) REDIS_SERVER = redis-server_$(REDIS_VERSION)_amd64.deb $(eval $(call add_derived_package,$(REDIS_TOOLS),$(REDIS_SERVER))) +REDIS_SERVER_DBG = redis-server-dbgsym_$(REDIS_VERSION)_amd64.deb +$(eval $(call add_derived_package,$(REDIS_SERVER),$(REDIS_SERVER_DBG))) + REDIS_SENTINEL = redis-sentinel_$(REDIS_VERSION)_amd64.deb $(REDIS_SENTINEL)_DEPENDS += $(REDIS_SERVER) $(REDIS_SENTINEL)_RDEPENDS += $(REDIS_SERVER) $(eval $(call add_derived_package,$(REDIS_TOOLS),$(REDIS_SENTINEL))) +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += redis + diff --git a/rules/sairedis.mk b/rules/sairedis.mk index fc481e620c..946787da0d 100644 --- a/rules/sairedis.mk +++ b/rules/sairedis.mk @@ -59,3 +59,9 @@ LIBSAIMETADATA_DBG = libsaimetadata-dbg_1.0.0_amd64.deb $(LIBSAIMETADATA_DBG)_DEPENDS += $(LIBSAIMETADATA) $(LIBSAIMETADATA_DBG)_RDEPENDS += $(LIBSAIMETADATA) $(eval $(call add_derived_package,$(LIBSAIREDIS),$(LIBSAIMETADATA_DBG))) + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += sonic-sairedis + diff --git a/rules/snmpd.mk b/rules/snmpd.mk index b7635cc7e0..9fb89c200c 100644 --- a/rules/snmpd.mk +++ b/rules/snmpd.mk @@ -26,6 +26,12 @@ $(SNMPD)_DEPENDS += $(LIBSNMP) $(SNMPD)_RDEPENDS += $(LIBSNMP) $(eval $(call add_derived_package,$(LIBSNMP_BASE),$(SNMPD))) +SNMP_DBG = snmp-dbgsym_$(SNMPD_VERSION_FULL)_amd64.deb +$(eval $(call add_derived_package,$(SNMP),$(SNMP_DBG))) + +SNMPD_DBG = snmpd-dbgsym_$(SNMPD_VERSION_FULL)_amd64.deb +$(eval $(call add_derived_package,$(SNMPD),$(SNMPD_DBG))) + LIBSNMP = libsnmp30_$(SNMPD_VERSION_FULL)_amd64.deb $(LIBSNMP)_RDEPENDS += $(LIBSNMP_BASE) $(eval $(call add_derived_package,$(LIBSNMP_BASE),$(LIBSNMP))) @@ -53,3 +59,9 @@ TKMIB = tkmib_$(SNMPD_VERSION_FULL)_all.deb $(TKMIB)_DEPENDS += $(LIBSNMP_PERL) $(TKMIB)_RDEPENDS += $(LIBSNMP_PERL) $(eval $(call add_derived_package,$(LIBSNMP_BASE),$(TKMIB))) + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += snmpd + diff --git a/rules/swss-common.mk b/rules/swss-common.mk index c8e21d7d5f..8fc2aa18a9 100644 --- a/rules/swss-common.mk +++ b/rules/swss-common.mk @@ -19,3 +19,9 @@ LIBSWSSCOMMON_DBG = libswsscommon-dbg_1.0.0_amd64.deb $(LIBSWSSCOMMON_DBG)_DEPENDS += $(LIBSWSSCOMMON) $(LIBSWSSCOMMON_DBG)_RDEPENDS += $(LIBSWSSCOMMON) $(eval $(call add_derived_package,$(LIBSWSSCOMMON),$(LIBSWSSCOMMON_DBG))) + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += sonic-swss-common + diff --git a/rules/swss.mk b/rules/swss.mk index 429eb63ae8..03a73778a7 100644 --- a/rules/swss.mk +++ b/rules/swss.mk @@ -11,3 +11,9 @@ SWSS_DBG = swss-dbg_1.0.0_amd64.deb $(SWSS_DBG)_DEPENDS += $(SWSS) $(SWSS_DBG)_RDEPENDS += $(SWSS) $(eval $(call add_derived_package,$(SWSS),$(SWSS_DBG))) + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += swss + diff --git a/rules/tacacs.mk b/rules/tacacs.mk index 2d08710550..c76e49155c 100644 --- a/rules/tacacs.mk +++ b/rules/tacacs.mk @@ -30,3 +30,8 @@ $(LIBNSS_TACPLUS)_SRC_PATH = $(SRC_PATH)/tacacs/nss SONIC_MAKE_DEBS += $(LIBNSS_TACPLUS) SONIC_STRETCH_DEBS += $(LIBPAM_TACPLUS) $(LIBNSS_TACPLUS) + +# The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} +# are archived into debug one image to facilitate debugging. +# +DBG_SRC_ARCHIVE += tacacs diff --git a/scripts/dbg_files.sh b/scripts/dbg_files.sh new file mode 100755 index 0000000000..1515639bc9 --- /dev/null +++ b/scripts/dbg_files.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# Provide file paths to archive for debug image as relative to src subdir +# +for i in $debug_src_archive +do + find $i/ -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -type f +done + diff --git a/slave.mk b/slave.mk index 05285971af..925cad3b32 100644 --- a/slave.mk +++ b/slave.mk @@ -581,6 +581,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ .platform \ onie-image.conf \ build_debian.sh \ + scripts/dbg_files.sh \ build_image.sh \ $$(addsuffix -install,$$(addprefix $(STRETCH_DEBS_PATH)/,$$($$*_DEPENDS))) \ $$(addprefix $(STRETCH_DEBS_PATH)/,$$($$*_INSTALLS)) \ @@ -621,6 +622,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ export swsssdk_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SWSSSDK_PY2))" export platform_common_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(SONIC_PLATFORM_COMMON_PY2))" export redis_dump_load_py2_wheel_path="$(addprefix $(PYTHON_WHEELS_PATH)/,$(REDIS_DUMP_LOAD_PY2))" + export install_debug_image="$(INSTALL_DEBUG_TOOLS)" $(foreach docker, $($*_DOCKERS),\ export docker_image="$(docker)" @@ -649,6 +651,9 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : \ chmod +x sonic_debian_extension.sh, ) + export debug_src_archive="$(DBG_SRC_ARCHIVE)" + + DEBUG_IMG="$(INSTALL_DEBUG_TOOLS)" \ USERNAME="$(USERNAME)" \ PASSWORD="$(PASSWORD)" \ ./build_debian.sh $(LOG) diff --git a/src/isc-dhcp/Makefile b/src/isc-dhcp/Makefile index 3994f7e4a4..384537b157 100644 --- a/src/isc-dhcp/Makefile +++ b/src/isc-dhcp/Makefile @@ -3,6 +3,7 @@ SHELL = /bin/bash .SHELLFLAGS += -e MAIN_TARGET = isc-dhcp-relay_$(ISC_DHCP_VERSION)_amd64.deb +DERIVED_TARGETS = isc-dhcp-relay-dbgsym_$(ISC_DHCP_VERSION)_amd64.deb $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Remove any stale files @@ -26,4 +27,6 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : popd # Move the newly-built .deb packages to the destination directory - mv $* $(DEST)/ + mv $(DERIVED_TARGETS) $* $(DEST)/ + +$(addprefix $(DEST)/, $(DERIVED_TARGETS)): $(DEST)/% : $(DEST)/$(MAIN_TARGET) diff --git a/src/libteam/Makefile b/src/libteam/Makefile index 15730885a8..7a05c48247 100644 --- a/src/libteam/Makefile +++ b/src/libteam/Makefile @@ -5,7 +5,10 @@ SHELL = /bin/bash MAIN_TARGET = libteam5_$(LIBTEAM_VERSION)_amd64.deb DERIVED_TARGETS = libteam-dev_$(LIBTEAM_VERSION)_amd64.deb \ libteamdctl0_$(LIBTEAM_VERSION)_amd64.deb \ - libteam-utils_$(LIBTEAM_VERSION)_amd64.deb + libteam-utils_$(LIBTEAM_VERSION)_amd64.deb \ + libteam5-dbgsym_$(LIBTEAM_VERSION)_amd64.deb \ + libteamdctl0-dbgsym_$(LIBTEAM_VERSION)_amd64.deb \ + libteam-utils-dbgsym_$(LIBTEAM_VERSION)_amd64.deb $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Obtain libteam diff --git a/src/libyang/Makefile b/src/libyang/Makefile index 99dedcd1a4..cb58f7c512 100644 --- a/src/libyang/Makefile +++ b/src/libyang/Makefile @@ -3,7 +3,7 @@ SHELL = /bin/bash .SHELLFLAGS += -e MAIN_TARGET = $(LIBYANG) -DERIVED_TARGETS = $(LIBYANG_DEV) +DERIVED_TARGETS = $(LIBYANG_DEV) $(LIBYANG_DBG) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -fr ./libyang-$(LIBYANG_VERSION) diff --git a/src/lldpd/Makefile b/src/lldpd/Makefile index 0d0dadbfde..285d7fec99 100644 --- a/src/lldpd/Makefile +++ b/src/lldpd/Makefile @@ -3,7 +3,7 @@ SHELL = /bin/bash .SHELLFLAGS += -e MAIN_TARGET = $(LLDPD) -DERIVED_TARGETS = $(LIBLLDPCTL) +DERIVED_TARGETS = $(LIBLLDPCTL) $(LLDPD_DBG) LLDP_URL = http://ftp.debian.org/debian/pool/main/l/lldpd diff --git a/src/lm-sensors/Makefile b/src/lm-sensors/Makefile index 182d6c84b0..1d24c7bfca 100644 --- a/src/lm-sensors/Makefile +++ b/src/lm-sensors/Makefile @@ -6,7 +6,10 @@ SHELL = /bin/bash MAIN_TARGET = $(LM_SENSORS) DERIVED_TARGETS = fancontrol_$(LM_SENSORS_VERSION_FULL)_all.deb \ libsensors4_$(LM_SENSORS_VERSION_FULL)_amd64.deb \ - sensord_$(LM_SENSORS_VERSION_FULL)_amd64.deb + sensord_$(LM_SENSORS_VERSION_FULL)_amd64.deb \ + $(LM_SENSORS_DBG) \ + $(LIBSENSORS_DBG) \ + $(SENSORD_DBG) $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -rf lm-sensors-$(LM_SENSORS_VERSION) diff --git a/src/radvd/Makefile b/src/radvd/Makefile index 40d384dbfe..b520f050d4 100644 --- a/src/radvd/Makefile +++ b/src/radvd/Makefile @@ -3,6 +3,7 @@ SHELL = /bin/bash .SHELLFLAGS += -e MAIN_TARGET = radvd_$(RADVD_VERSION)_amd64.deb +DERIVED_TARGETS = radvd-dbgsym_$(RADVD_VERSION)_amd64.deb $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : # Remove any stale files @@ -28,4 +29,4 @@ $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : popd # Move the newly-built .deb package to the destination directory - mv $* $(DEST)/ + mv $(DERIVED_TARGETS) $* $(DEST)/ diff --git a/src/redis/Makefile b/src/redis/Makefile index afb4c2a7d2..04133820f0 100644 --- a/src/redis/Makefile +++ b/src/redis/Makefile @@ -7,7 +7,8 @@ REDIS_VERSION_FULL = $(REDIS_VERSION)-1~bpo8+1 MAIN_TARGET = redis-server_$(REDIS_VERSION_FULL)_amd64.deb DERIVED_TARGETS = redis-tools_$(REDIS_VERSION_FULL)_amd64.deb \ - redis-sentinel_$(REDIS_VERSION_FULL)_amd64.deb + redis-sentinel_$(REDIS_VERSION_FULL)_amd64.deb \ + redis-server-dbgsym_$(REDIS_VERSION_FULL)_amd64.deb $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : rm -rf redis_build diff --git a/src/snmpd/Makefile b/src/snmpd/Makefile index e9645b93b6..d20468cdbd 100644 --- a/src/snmpd/Makefile +++ b/src/snmpd/Makefile @@ -6,6 +6,8 @@ MAIN_TARGET = libsnmp-base_$(SNMPD_VERSION_FULL)_all.deb DERIVED_TARGETS = snmptrapd_$(SNMPD_VERSION_FULL)_amd64.deb \ snmp_$(SNMPD_VERSION_FULL)_amd64.deb \ snmpd_$(SNMPD_VERSION_FULL)_amd64.deb \ + snmp-dbgsym_$(SNMPD_VERSION_FULL)_amd64.deb \ + snmpd-dbgsym_$(SNMPD_VERSION_FULL)_amd64.deb \ libsnmp30_$(SNMPD_VERSION_FULL)_amd64.deb \ libsnmp30-dbg_$(SNMPD_VERSION_FULL)_amd64.deb \ libsnmp-dev_$(SNMPD_VERSION_FULL)_amd64.deb \