annotate.c (3ee2eb6da20db1edad31070da38996e8e0f8adfa) annotate.c (e216874cc1946d28084fa90e495e02725a29e25f)
1/*
2 * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
3 *
4 * Parts came from builtin-annotate.c, see those files for further
5 * copyright notes.
6 *
7 * Released under the GPL v2. (and only v2, not any later version)
8 */

--- 216 unchanged lines hidden (view full) ---

225 const char *s = strchr(ops->raw, '+');
226 const char *c = strchr(ops->raw, ',');
227
228 if (c++ != NULL)
229 ops->target.addr = strtoull(c, NULL, 16);
230 else
231 ops->target.addr = strtoull(ops->raw, NULL, 16);
232
1/*
2 * Copyright (C) 2011, Red Hat Inc, Arnaldo Carvalho de Melo <acme@redhat.com>
3 *
4 * Parts came from builtin-annotate.c, see those files for further
5 * copyright notes.
6 *
7 * Released under the GPL v2. (and only v2, not any later version)
8 */

--- 216 unchanged lines hidden (view full) ---

225 const char *s = strchr(ops->raw, '+');
226 const char *c = strchr(ops->raw, ',');
227
228 if (c++ != NULL)
229 ops->target.addr = strtoull(c, NULL, 16);
230 else
231 ops->target.addr = strtoull(ops->raw, NULL, 16);
232
233 if (s++ != NULL)
233 if (s++ != NULL) {
234 ops->target.offset = strtoull(s, NULL, 16);
234 ops->target.offset = strtoull(s, NULL, 16);
235 else
236 ops->target.offset = UINT64_MAX;
235 ops->target.offset_avail = true;
236 } else {
237 ops->target.offset_avail = false;
238 }
237
238 return 0;
239}
240
241static int jump__scnprintf(struct ins *ins, char *bf, size_t size,
242 struct ins_operands *ops)
243{
239
240 return 0;
241}
242
243static int jump__scnprintf(struct ins *ins, char *bf, size_t size,
244 struct ins_operands *ops)
245{
244 if (!ops->target.addr)
246 if (!ops->target.addr || ops->target.offset < 0)
245 return ins__raw_scnprintf(ins, bf, size, ops);
246
247 return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target.offset);
248}
249
250static struct ins_ops jump_ops = {
251 .parse = jump__parse,
252 .scnprintf = jump__scnprintf,

--- 951 unchanged lines hidden (view full) ---

1204
1205 dl = disasm_line__new(offset, parsed_line, privsize, *line_nr, arch, map);
1206 free(line);
1207 (*line_nr)++;
1208
1209 if (dl == NULL)
1210 return -1;
1211
247 return ins__raw_scnprintf(ins, bf, size, ops);
248
249 return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, ops->target.offset);
250}
251
252static struct ins_ops jump_ops = {
253 .parse = jump__parse,
254 .scnprintf = jump__scnprintf,

--- 951 unchanged lines hidden (view full) ---

1206
1207 dl = disasm_line__new(offset, parsed_line, privsize, *line_nr, arch, map);
1208 free(line);
1209 (*line_nr)++;
1210
1211 if (dl == NULL)
1212 return -1;
1213
1212 if (dl->ops.target.offset == UINT64_MAX)
1214 if (!disasm_line__has_offset(dl)) {
1213 dl->ops.target.offset = dl->ops.target.addr -
1214 map__rip_2objdump(map, sym->start);
1215 dl->ops.target.offset = dl->ops.target.addr -
1216 map__rip_2objdump(map, sym->start);
1217 dl->ops.target.offset_avail = true;
1218 }
1215
1216 /* kcore has no symbols, so add the call target name */
1217 if (dl->ins.ops && ins__is_call(&dl->ins) && !dl->ops.target.name) {
1218 struct addr_map_symbol target = {
1219 .map = map,
1220 .addr = dl->ops.target.addr,
1221 };
1222

--- 680 unchanged lines hidden ---
1219
1220 /* kcore has no symbols, so add the call target name */
1221 if (dl->ins.ops && ins__is_call(&dl->ins) && !dl->ops.target.name) {
1222 struct addr_map_symbol target = {
1223 .map = map,
1224 .addr = dl->ops.target.addr,
1225 };
1226

--- 680 unchanged lines hidden ---