--dump-raw-trace::
         Dump raw trace in ASCII.
 
--g [type,min[,limit],order]::
+-g [type,min[,limit],order[,key]]::
 --call-graph::
         Display call chains using type, min percent threshold, optional print
        limit and order.
        - callee: callee based call graph.
        - caller: inverted caller based call graph.
 
-       Default: fractal,0.5,callee.
+       key can be:
+       - function: compare on functions
+       - address: compare on individual code addresses
+
+       Default: fractal,0.5,callee,function.
 
 -G::
 --inverted::
 
        }
 
        /* get the call chain order */
-       if (!strcmp(tok2, "caller"))
+       if (!strncmp(tok2, "caller", strlen("caller")))
                callchain_param.order = ORDER_CALLER;
-       else if (!strcmp(tok2, "callee"))
+       else if (!strncmp(tok2, "callee", strlen("callee")))
                callchain_param.order = ORDER_CALLEE;
        else
                return -1;
+
+       /* Get the sort key */
+       tok2 = strtok(NULL, ",");
+       if (!tok2)
+               goto setup;
+       if (!strncmp(tok2, "function", strlen("function")))
+               callchain_param.key = CCKEY_FUNCTION;
+       else if (!strncmp(tok2, "address", strlen("address")))
+               callchain_param.key = CCKEY_ADDRESS;
+       else
+               return -1;
 setup:
        if (callchain_register_param(&callchain_param) < 0) {
                fprintf(stderr, "Can't register callchain params\n");
        OPT_BOOLEAN('x', "exclude-other", &symbol_conf.exclude_other,
                    "Only display entries with parent-match"),
        OPT_CALLBACK_DEFAULT('g', "call-graph", &report, "output_type,min_percent[,print_limit],call_order",
-                    "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit and callchain order. "
-                    "Default: fractal,0.5,callee", &parse_callchain_opt, callchain_default_opt),
+                    "Display callchains using output_type (graph, flat, fractal, or none) , min percent threshold, optional print limit, callchain order, key (function or address). "
+                    "Default: fractal,0.5,callee,function", &parse_callchain_opt, callchain_default_opt),
        OPT_BOOLEAN('G', "inverted", &report.inverted_callchain,
                    "alias for inverted call graph"),
        OPT_CALLBACK(0, "ignore-callees", NULL, "regex",
 
 #include <errno.h>
 #include <math.h>
 
+#include "hist.h"
 #include "util.h"
 #include "callchain.h"
 
        /*
         * Lookup in the current node
         * If we have a symbol, then compare the start to match
-        * anywhere inside a function.
+        * anywhere inside a function, unless function
+        * mode is disabled.
         */
        list_for_each_entry(cnode, &root->val, list) {
                struct callchain_cursor_node *node;
 
                sym = node->sym;
 
-               if (cnode->ms.sym && sym) {
+               if (cnode->ms.sym && sym &&
+                   callchain_param.key == CCKEY_FUNCTION) {
                        if (cnode->ms.sym->start != sym->start)
                                break;
                } else if (cnode->ip != node->ip)