Shimano shifter neither reaching top nor bottom gear
Common reasons for a derailleur not getting to the low gears (larger sprockets) is the shift cable slipping through the pinch bolt that secures it on the derailleur, cable housing has come out of shifters or frame stops or bad adjustment via the barrel adjusters.
The common reason for a derailleur not getting to the high gears (smaller sprockets) is the cable hanging up in the cable housing and preventing the derailleur spring from moving the cage outwards.
First follow the cable run from the shifter to the check the cable housing is properly inserted in the shifter and all frame stops.
Detach the cable from the derailleur, tension the cable by pulling on it with a pair of pliers, work the shifter and make sure it shifts through all gears and pulls in and lest out the cable smoothly. If the cable does not move through the housing smoothly take the cable out and wipe it off, if you still have problems replace the cable and housing.
With the back wheel of the ground, manually pedal and carefully push the derailleur cage in to make sure it will move between the smallest and largest sprockets. If the derailleur range is too limited check the limit adjustments and look for anything jamming the parallelogram.
Reattach the shift cable and follow a guide for derailleur set up and adjustment. Park Tool has a really good one.
Cleaning the chain, derailleur jockey wheels and sprockets and re-lubing the chain will help also.