This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: break on C++ global objects ctors
- From: Daniel Gutson <daniel dot gutson at tallertechnologies dot com>
- To: Paul_Koning at dell dot com
- Cc: gdb-patches <gdb-patches at sourceware dot org>
- Date: Mon, 31 Mar 2014 11:10:07 -0300
- Subject: Re: break on C++ global objects ctors
- Authentication-results: sourceware.org; auth=none
- References: <CAF5HaEU_5DhgydC0B7Ucx+owH3+PqsztZphAARzc80+9VBBtBA at mail dot gmail dot com> <CAF5HaEU3nmr9Ak5dGByUPfe0JGn4NwHu_5JUpB7Fsn6CjfuzOw at mail dot gmail dot com> <C75A84166056C94F84D238A44AF9F6AD16C9B3FB at AUSX10MPC103 dot AMER dot DELL dot COM>
On Mon, Mar 31, 2014 at 10:56 AM, <Paul_Koning@dell.com> wrote:
> This certainly should be easily doable, just in gdb. FWIW, if you start a program with gdbserver and then connect to it from gdb ("target remote" to gdbserver), the program is stopped at the first instruction, way before "main".
That doesn't solve how gdb detects the beginning of each ctor function.
At that point you should be able to set a breakpoint in a
constructor and tell it "continue".
>
> If such a thing were desirable for gdb, the same logic could be used, I would assume.
>
> paul
>
> On Mar 31, 2014, at 8:24 AM, Daniel Gutson <daniel.gutson@tallertechnologies.com> wrote:
>
>> PING for a maintainer please?
>>
>> Thanks!
>>
>> Daniel.
>>
>> On Wed, Mar 26, 2014 at 3:22 PM, Daniel Gutson
>> <daniel.gutson@tallertechnologies.com> wrote:
>>> Hi,
>>>
>>> AFAIK, there is no command to break and debug the construction of
>>> global objects in C++.
>>>
>>> I'm looking for an equivalent command to "start" but instead of temp
>>> breaking at the
>>> beginning of main(), breaks at the beginning of every global ctor.
>>>
>>> The way I'm currently doing this in GNU Linux/x86_64 is:
>>> br __static_initialization_and_destruction_0
>>> which is a workaround, with the nice side effect that when asking info br, gdb
>>> shows all the source locations of the global object instances.
>>>
>>> I'm not sure whether this could supported by a native gdb feature or by a python
>>> extension.
>>> If there is consensus about the former, I might create some patch.
>>> However, I suspect that this might require some support from collect2 too,
>>> or some libc internals knowledge by gdb.
>>>
>>> Daniel.
>>
>>
>>
>> --
>>
>> Daniel F. Gutson
>> Chief Engineering Officer, SPD
>>
>>
>> San Lorenzo 47, 3rd Floor, Office 5
>>
>> Córdoba, Argentina
>>
>>
>> Phone: +54 351 4217888 / +54 351 4218211
>>
>> Skype: dgutson
--
Daniel F. Gutson
Chief Engineering Officer, SPD
San Lorenzo 47, 3rd Floor, Office 5
Córdoba, Argentina
Phone: +54 351 4217888 / +54 351 4218211
Skype: dgutson