Using "debug" in "Arduino Pro micro" will make the program run abnormally

What’s the platformio.ini?

From the program code it doesn’t look like you’re using avr-stub to debug a real device, but rather the default simavr. This is a simulation program and will not access your real hardware. If you want to debug on real hardware you must not use the Serial and add debugging per this.