* Referencing C++ functions with non-demangled names. @ 2001-05-21 11:24 Daniel Manfis 2001-05-21 18:23 ` Daniel Berlin 0 siblings, 1 reply; 4+ messages in thread From: Daniel Manfis @ 2001-05-21 11:24 UTC (permalink / raw) To: gdb Hello. If i want to set breakpoint on a C++ function, how could i do it using it's usual and not mangled name? I tried to turn on "set print demangle" and "set print asm-demangle", but it doesn't help: whenever i try to put breakpoint on a C++ function (in my own code) with it's non-demangled name (like: 'break main.cc:f'), i get a message: 'function "f" not defined' and i have to either use mangled name or line number. Daniel. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Referencing C++ functions with non-demangled names. 2001-05-21 11:24 Referencing C++ functions with non-demangled names Daniel Manfis @ 2001-05-21 18:23 ` Daniel Berlin 2001-05-22 3:13 ` Daniel Manfis 0 siblings, 1 reply; 4+ messages in thread From: Daniel Berlin @ 2001-05-21 18:23 UTC (permalink / raw) To: dany_100; +Cc: gdb "Daniel Manfis" <dany_100@yahoo.com> writes: > Hello. > > If i want to set breakpoint on a C++ function, how could i do it > using it's usual and not mangled name? I tried to turn on > "set print demangle" and "set print asm-demangle", but it doesn't > help: whenever i try to put breakpoint on a C++ function (in my own > code) with it's non-demangled name (like: 'break main.cc:f'), i get a > message: > > 'function "f" not defined' > > and i have to either use mangled name or line number. Errr, I need a test case, it works fine here. I also need to know what compiler version, etc, you are using. The workaround is to quote it, or remove the filename: from the front (or both). C++ functions with the same name must be the same function, by the one definition rule, so prefixing it like that is pointless. Regardless, even if the workaround works, some more information would be helpful, since i can't reproduce this problem with any compilers i have around here. --Dan -- "I saw a subliminal advertising executive, but only for a second. "-Steven Wright ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Referencing C++ functions with non-demangled names. 2001-05-21 18:23 ` Daniel Berlin @ 2001-05-22 3:13 ` Daniel Manfis 2001-05-22 6:29 ` Daniel Berlin 0 siblings, 1 reply; 4+ messages in thread From: Daniel Manfis @ 2001-05-22 3:13 UTC (permalink / raw) To: gdb > Errr, I need a test case, it works fine here. > I also need to know what compiler version, etc, you are using. linux : Mandrake 7.2 (kernel 2.2.17-21mdk) gcc : 3.0, snapshot 20010423 gdb : 5.0 (RPM from/for Mandrake 7.2) test case: ////////////////////////////////////////////////////////////////////// // File name : a.cc void f() {} int main() { f() ; } ////////////////////////////////////////////////////////////////////// I compile with one of the following options, all of them give the same results: g++ -ggdb3 a.cc g++ -g3 a.cc g++ -gstabs+3 a.cc > The workaround is to quote it, or remove the filename: from the > front (or both). C++ functions with the same name must be the same > function, by the one definition rule, so prefixing it like that is > pointless. Here is what i tried to do to set a breakpoint on functoin 'f', all of the methods failing: break a.cc:f break 'a.cc:f' break f break 'f' (i couldn't use double-quotes: when i try to do that (break "f"), gdb crashes with segmentation fault (as it is, by the way, when you type "break .")). But i could set a breakpoint on 'f' function with the following expression: break _Z1fv The only function breakpoint i could set using function's non-mangled name, is the 'main' function breakpoint (using "break main" expression. Probably the reason i succeeded to set breakpoint on 'main' with it's non-mangled name, is because it's name is not mangled (at least when i step through the program, gdb never prints 'main''s name in a mangled form, as it does with all the other C++ functions). Also, i couldn't set breakpoints on functions in a namespaces unless i use it's mangled name, a notation like "break 'ns::f'" won't do (instead, provided there is function 'f' in a namespace 'ns', i have to use "break _ZN2ns1fEv") Generally, namespaces are not recognized at all. For example, if i type "break ns::" and press <ESC-?>, instead of displaying functions from that namespace, all functions in the scope are displayed (as it happens when you type "break" and press <ESC-?>). I thought that maybe there is a problem with gdb's RPM package i am using, but it is impossible for me to check - i barely have a space to ungzip a source package, let along build it. Daniel. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Referencing C++ functions with non-demangled names. 2001-05-22 3:13 ` Daniel Manfis @ 2001-05-22 6:29 ` Daniel Berlin 0 siblings, 0 replies; 4+ messages in thread From: Daniel Berlin @ 2001-05-22 6:29 UTC (permalink / raw) To: dany_100; +Cc: gdb "Daniel Manfis" <dany_100@yahoo.com> writes: > > Errr, I need a test case, it works fine here. > > I also need to know what compiler version, etc, you are using. > > linux : Mandrake 7.2 (kernel 2.2.17-21mdk) > gcc : 3.0, snapshot 20010423 > gdb : 5.0 (RPM from/for Mandrake 7.2) You can't use gdb 5.0 with gcc 3.0 snapshots and expect it to work. GDB 5 was released before gcc 3.0 even branched, and doesn't have support for the newer demangling style. Use a newer gdb (like a snapshot), and it should work fine. > to use "break _ZN2ns1fEv") Generally, namespaces are not recognized > at all. For example, if i type "break ns::" and press <ESC-?>, > instead of displaying functions from that namespace, all functions in > the scope are displayed (as it happens when you type "break" and > press <ESC-?>). Once again, you have to quote it to get completion to work in 5.0. It's a bug that's particularly heinous to fix in a clean way. -- "I have a friend named Dennis. Both of his parents were midgets, but he isn't a midget. He's a midget-dwarf. He's two inches tall. He's the one who poses for trophies. "-Steven Wright ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-05-22 6:29 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2001-05-21 11:24 Referencing C++ functions with non-demangled names Daniel Manfis 2001-05-21 18:23 ` Daniel Berlin 2001-05-22 3:13 ` Daniel Manfis 2001-05-22 6:29 ` Daniel Berlin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox