  Given a $D$-module $M$ generated by a single element, and a polynomial $f$,
one can construct several $D$-modules attached to $M$ and $f$ and can define
the notion of the (generalized) $b$-function following M. Kashiwara. These
modules are closely related to the localization and the local cohomology of
$M$. We show that the $b$-function, if it exists, controls these modules and
present general algorithms for computing these modules and the $b$-function (if
it exists) without any further assumptions. For these algorithms, we
reformulate the localization algorithm for $D$-modules.
