Try this:

    PACKAGES := "${@oe_filter_out('gdbserver' if '${TCMODE}'.startswith('external-sourcery') else '$', '${PACKAGES}', d)}"