public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [Bug tapsets/23506] New: tapset function usymname() cannot translate the addresses of C static/global variables
@ 2018-08-10 18:13 agentzh at gmail dot com
  2018-08-10 18:17 ` [Bug tapsets/23506] " agentzh at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: agentzh at gmail dot com @ 2018-08-10 18:13 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=23506

            Bug ID: 23506
           Summary: tapset function usymname() cannot translate the
                    addresses of C static/global variables
           Product: systemtap
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tapsets
          Assignee: systemtap at sourceware dot org
          Reporter: agentzh at gmail dot com
  Target Milestone: ---

Consider the following C program:

```C
int a = 3;
void *p = &a;

int main(void) {
    return 0;
}
```

Compile it:

```
gcc -Wall -g a.c
```

Then run it with stap:

```
$ stap -e 'probe process.function("main") { p = @var("p");
println(usymname(p)); exit() }' -c ./a.out
0x601020
```

It fails to return the string "a", which is the global C variable name in the
target program.

GDB does support resolving global C variables by default. For this example:

```
(gdb) p p
$3 = (void *) 0x601020 <a>
```

We've got the variable symbol name `a` in the `p` command output here.

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug tapsets/23506] tapset function usymname() cannot translate the addresses of C static/global variables
  2018-08-10 18:13 [Bug tapsets/23506] New: tapset function usymname() cannot translate the addresses of C static/global variables agentzh at gmail dot com
@ 2018-08-10 18:17 ` agentzh at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: agentzh at gmail dot com @ 2018-08-10 18:17 UTC (permalink / raw)
  To: systemtap

https://sourceware.org/bugzilla/show_bug.cgi?id=23506

--- Comment #1 from agentzh <agentzh at gmail dot com> ---
Or just use literal address values in GDB:

```
(gdb) p (void*)0x601020
$6 = (void *) 0x601020 <a>
```

It works too :)

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-08-10 18:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-10 18:13 [Bug tapsets/23506] New: tapset function usymname() cannot translate the addresses of C static/global variables agentzh at gmail dot com
2018-08-10 18:17 ` [Bug tapsets/23506] " agentzh at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).