To rack one's brains

to exert one's thinking processes to the utmost for the purpose of accomplishing something; as, I racked my brains out trying to find a way to solve the problem.

See also: Rack

Webster's Revised Unabridged Dictionary, published 1913 by G. & C. Merriam Co.