Michael’s fix also fixes my bug, so that’s fine with me.
(But to answer your question, the problem was that ‘dh -Xfilename’ called ‘dh_strip -O-Xfilename’, which triggered
case "${p#-O}" in
…
-X*) xopts="$xopts $p"
;;
and added -O-Xfilename to $xopts rather than -Xfilename, confusing pkg_create_dbgsym. My fix stripped the -O while assigning to xopts, and Michael’s fix strips the -O in place before the case statement. The latter is probably better because it would also work for -O-p, -O-N, -O-P.)
Michael’s fix also fixes my bug, so that’s fine with me.
(But to answer your question, the problem was that ‘dh -Xfilename’ called ‘dh_strip -O-Xfilename’, which triggered
xopts= "$xopts $p"
case "${p#-O}" in
…
-X*)
;;
and added -O-Xfilename to $xopts rather than -Xfilename, confusing pkg_create_dbgsym. My fix stripped the -O while assigning to xopts, and Michael’s fix strips the -O in place before the case statement. The latter is probably better because it would also work for -O-p, -O-N, -O-P.)