Add check to prevent attaching a profiler when one is already present (#25520)