[Lazarus] Getting sourceline from stacktrace address

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Getting sourceline from stacktrace address

Free Pascal - Lazarus mailing list
Good evening,

how can i get the sourceline from a stacktrace address?

I use heaptrc to find a double free. The problem is that producing the stacktrace on double free
also runs into the error and only produces the list of addresses. KeepReleased is not an option here
due to limited memory. 48 GB is not enough ;-(

Lazarus trunk, fpc trunk, x86_64, fpDebug, Dwarf3, Windows 10 20H2


Pascal


--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Getting sourceline from stacktrace address

Free Pascal - Lazarus mailing list
El 21/12/20 a les 20:12, Pascal Riekenberg via lazarus ha escrit:

> Good evening,
>
> how can i get the sourceline from a stacktrace address?
>
> I use heaptrc to find a double free. The problem is that producing the
> stacktrace on double free
> also runs into the error and only produces the list of addresses.
> KeepReleased is not an option here
> due to limited memory. 48 GB is not enough ;-(
>
> Lazarus trunk, fpc trunk, x86_64, fpDebug, Dwarf3, Windows 10 20H2
>

I don't know with X86_64, but with windows 32 I load the exe in gdb then

info line *0x01234abcd

Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Getting sourceline from stacktrace address

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On 21/12/2020 20:12, Pascal Riekenberg via lazarus wrote:
Good evening,

how can i get the sourceline from a stacktrace address?

I use heaptrc to find a double free. The problem is that producing the stacktrace on double free
also runs into the error and only produces the list of addresses. KeepReleased is not an option here
due to limited memory. 48 GB is not enough ;-(

Lazarus trunk, fpc trunk, x86_64, fpDebug, Dwarf3, Windows 10 20H2

If you have the exe, and the exe has debug info:
- paste the stacktrace into menu: View > Leaks and traces
- Press "Resolve" and select the exe.

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Getting sourceline from stacktrace address

Free Pascal - Lazarus mailing list
On 21/12/2020 20:27, Martin Frb via lazarus wrote:
On 21/12/2020 20:12, Pascal Riekenberg via lazarus wrote:
Good evening,

how can i get the sourceline from a stacktrace address?

I use heaptrc to find a double free. The problem is that producing the stacktrace on double free


Also if you are on Linux: compile with: -gv

And use
valgrind --tool=memcheck yourapp

This should get you much better info.
- Trace for access after free
- Trace for the free call
- Trace where it was allocated

Though, your app will run a lot slower in valgrind....

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Getting sourceline from stacktrace address

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
Thanks! That works. But with many manual copy and paste.


Pascal

> Luca Olivetti via lazarus <[hidden email]> hat am 21.12.2020 20:21 geschrieben:
>
>  
> El 21/12/20 a les 20:12, Pascal Riekenberg via lazarus ha escrit:
> > Good evening,
> >
> > how can i get the sourceline from a stacktrace address?
> >
> > I use heaptrc to find a double free. The problem is that producing the
> > stacktrace on double free
> > also runs into the error and only produces the list of addresses.
> > KeepReleased is not an option here
> > due to limited memory. 48 GB is not enough ;-(
> >
> > Lazarus trunk, fpc trunk, x86_64, fpDebug, Dwarf3, Windows 10 20H2
> >
>
> I don't know with X86_64, but with windows 32 I load the exe in gdb then
>
> info line *0x01234abcd
>
> Bye
> --
> Luca Olivetti
> Wetron Automation Technology http://www.wetron.es/
> Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007
> --
> _______________________________________________
> lazarus mailing list
> [hidden email]
> https://lists.lazarus-ide.org/listinfo/lazarus
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Getting sourceline from stacktrace address

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
Thanks! This works even better and also with direct jump to source.


Pascal

Martin Frb via lazarus <[hidden email]> hat am 21.12.2020 20:27 geschrieben:


On 21/12/2020 20:12, Pascal Riekenberg via lazarus wrote:
Good evening,

how can i get the sourceline from a stacktrace address?

I use heaptrc to find a double free. The problem is that producing the stacktrace on double free
also runs into the error and only produces the list of addresses. KeepReleased is not an option here
due to limited memory. 48 GB is not enough ;-(

Lazarus trunk, fpc trunk, x86_64, fpDebug, Dwarf3, Windows 10 20H2

If you have the exe, and the exe has debug info:
- paste the stacktrace into menu: View > Leaks and traces
- Press "Resolve" and select the exe.
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Getting sourceline from stacktrace address

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On 21/12/2020 20:54, Pascal Riekenberg via lazarus wrote:
> Thanks! That works. But with many manual copy and paste.
>

You can redirect the output to a foo.trc file. Then load it. (must end
in trc).

You can also paste more than one trace in a single go. (including the
lines that heaptrc outputs between the traces / and even include
other/random lines/output)
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Getting sourceline from stacktrace address

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
On 21/12/2020 20:55, Pascal Riekenberg via lazarus wrote:
Thanks! This works even better and also with direct jump to source.

The resolved lines from the heaptrc should also jump to source.

If not, can I have examples?

And  a screenshot what was shown after resolve (or the exe to resolve the example)?

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Getting sourceline from stacktrace address

Free Pascal - Lazarus mailing list
Martin Frb via lazarus <[hidden email]> hat am 21.12.2020 21:11 geschrieben:


On 21/12/2020 20:55, Pascal Riekenberg via lazarus wrote:
Thanks! This works even better and also with direct jump to source.

The resolved lines from the heaptrc should also jump to source.
Yes, works like a charm ;-)

What about resolving to exe of current project instead of searching for exe manualy, at least as option?

If not, can I have examples?

And  a screenshot what was shown after resolve (or the exe to resolve the example)?
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Getting sourceline from stacktrace address

Free Pascal - Lazarus mailing list
On 21/12/2020 21:33, Pascal Riekenberg via lazarus wrote:
The resolved lines from the heaptrc should also jump to source.
Yes, works like a charm ;-)

What about resolving to exe of current project instead of searching for exe manualy, at least as option?

Its an idea, yes.

The original use case was for dealing with traces from releases.
- build your release (with ability to log traces to a file) with debug line
- take a copy
- strip the release / ship it
Now if anyone got an error in the release, they could send the logfile, and you could use the addresses, to get full source info.

But it then also became useful, because the build in trace dump would sometimes stop resolving (if it encountered just ONE address that did not resolve).
So for that, the current exe is an option.

Important is, that the exe was not rebuild since the trace was done. => New build => new address to line mapping (at least potentially).

You can make a feature request. But it will be a while before I can even look at it.

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus