We examine how future gravitational-wave measurements from merging black holes (BHs) can be used to infer the shape of the black-hole mass function, with important implications for the study of star formation and evolution and the properties of binary BHs. We model the mass function as a power law, inherited from the stellar initial mass function, and introduce lower and upper mass cutoff parameterizations in order to probe the minimum and maximum BH masses allowed by stellar evolution, respectively. We initially focus on the heavier BH in each binary, to minimize model dependence. Taking into account the experimental noise, the mass measurement errors and the uncertainty in the redshift-dependence of the merger rate, we show that the mass function parameters, as well as the total rate of merger events, can be measured to < 10% accuracy within a few years of advanced LIGO observations at its design sensitivity. This can be used to address important open questions such as the upper limit on the stellar mass which allows for BH formation and to confirm or refute the currently observed mass gap between neutron stars and BHs. In order to glean information on the progenitors of the merging BH binaries, we then advocate the study of the two-dimensional mass distribution to constrain parameters that describe the two-body system, such as the mass ratio between the two BHs, in addition to the merger rate and mass function parameters. We argue that several years of data collection can efficiently probe models of binary formation, and show, as an example, that the hypothesis that some gravitational-wave events may involve primordial black holes can be tested. Finally, we point out that in order to maximize the constraining power of the data, it may be worthwhile to lower the signal-to-noise threshold imposed on each candidate event and amass a larger statistical ensemble of BH mergers.