Retirement tax questions

When I finally take a distribution from my roth 401k, how will I know the final dollar amount that is to be double-taxed? I know how much I overfunded today, but how can I determine the attributable earnings after 20+ years?