Discussion:
[mongodb-dev] Need help with debugging
Ricardo Amendoeira
2017-01-20 10:50:20 UTC
Permalink
Hello,

I want to implement a new type of sharding (by 2dsphere coordinates) to
MongoDB as part of my thesis.
I'm having a really hard time with debugging on Linux.

I have compiled mongo, mongod and mongos with the --dbg=on and --opt=off
options, I run Nemiver (a gdb frontend) with the mongos from
build/debug/mongo, with the working directory build/debug/mongo.

When I set my breakpoints they do stop the program execution but I can't
see local variables (other than some local variable called 'indexes' which
seems useless to me) and when I click next it often complains that it can't
find a source file (the file it looks for seems to be a temporary file
created during the build process, which indeed does not exist) and jumps to
assembly.

I think part of my problem is that mongos has more than one thread, is
there a way to compile it to use a single thread?
The issue regarding the missing source file I'm not sure what it could be,
any ideas?

What best practices are there for debugging mongodb and what tools do you
recommend?

Thank you :)
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/fa3e115a-e7af-4da7-9793-2084762d0b19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ricardo Amendoeira
2017-01-20 11:29:05 UTC
Permalink
(I tried using gdb and I've already confirmed that there are about 9
threads that startup with mongos)
Post by Ricardo Amendoeira
Hello,
I want to implement a new type of sharding (by 2dsphere coordinates) to
MongoDB as part of my thesis.
I'm having a really hard time with debugging on Linux.
I have compiled mongo, mongod and mongos with the --dbg=on and --opt=off
options, I run Nemiver (a gdb frontend) with the mongos from
build/debug/mongo, with the working directory build/debug/mongo.
When I set my breakpoints they do stop the program execution but I can't
see local variables (other than some local variable called 'indexes' which
seems useless to me) and when I click next it often complains that it can't
find a source file (the file it looks for seems to be a temporary file
created during the build process, which indeed does not exist) and jumps to
assembly.
I think part of my problem is that mongos has more than one thread, is
there a way to compile it to use a single thread?
The issue regarding the missing source file I'm not sure what it could be,
any ideas?
What best practices are there for debugging mongodb and what tools do you
recommend?
Thank you :)
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/7b0c8402-6a09-49f1-877e-f61548b1c566%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ricardo Amendoeira
2017-01-20 14:09:26 UTC
Permalink
PS: So I have been trying with gdb to see if it would help. It does show me
the threads that exist and allows me to switch between them but I can't
find a way to add breakpoints to a function in an anonymous namespace or by
file name.
gdb also makes it hard to read the code and get context, if it's the only
option that's ok but if someone knows of a nice alternative, please tell me
:)

I'm sorry if these questions are somewhat annoying, I'm not experienced
with C++ but I have used C for a while.

Thanks :)
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/85f9b89c-0f9e-425a-9681-dd9a7e2de2b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'Eric Milkie' via mongodb-dev
2017-01-20 14:37:42 UTC
Permalink
Hi Ricardo,
I've had good luck setting breakpoints using the filename/line number
format:
br myfile.cpp:155
-Eric

On Fri, Jan 20, 2017 at 9:09 AM, Ricardo Amendoeira <
Post by Ricardo Amendoeira
PS: So I have been trying with gdb to see if it would help. It does show
me the threads that exist and allows me to switch between them but I can't
find a way to add breakpoints to a function in an anonymous namespace or by
file name.
gdb also makes it hard to read the code and get context, if it's the only
option that's ok but if someone knows of a nice alternative, please tell me
:)
I'm sorry if these questions are somewhat annoying, I'm not experienced
with C++ but I have used C for a while.
Thanks :)
--
You received this message because you are subscribed to the Google Groups
"mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/
msgid/mongodb-dev/85f9b89c-0f9e-425a-9681-dd9a7e2de2b6%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-dev/85f9b89c-0f9e-425a-9681-dd9a7e2de2b6%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/CAJBhJ-5rC6ontd-vYaQDnZNwZYOxNigwzSaHNa2Ja94XyPBeJg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
'Mathias Stearn' via mongodb-dev
2017-01-20 17:06:34 UTC
Permalink
FYI we now have enhanced GDB integration, including pretty-printers for
many of our internal types. You will have a better experience if you add
our .gdbinit file to your whitelist or source it directly:
https://github.com/mongodb/mongo/blob/master/.gdbinit

The syntax gdb uses for anonymous namespaces is a little weird, but
(usually) this works (the single quotes ARE important): 'mongo::(anonymous
namespace)::someName'

On Fri, Jan 20, 2017 at 9:37 AM, 'Eric Milkie' via mongodb-dev <
Post by 'Eric Milkie' via mongodb-dev
Hi Ricardo,
I've had good luck setting breakpoints using the filename/line number
br myfile.cpp:155
-Eric
On Fri, Jan 20, 2017 at 9:09 AM, Ricardo Amendoeira <
Post by Ricardo Amendoeira
PS: So I have been trying with gdb to see if it would help. It does show
me the threads that exist and allows me to switch between them but I can't
find a way to add breakpoints to a function in an anonymous namespace or by
file name.
gdb also makes it hard to read the code and get context, if it's the only
option that's ok but if someone knows of a nice alternative, please tell me
:)
I'm sorry if these questions are somewhat annoying, I'm not experienced
with C++ but I have used C for a while.
Thanks :)
--
You received this message because you are subscribed to the Google Groups
"mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/ms
gid/mongodb-dev/85f9b89c-0f9e-425a-9681-dd9a7e2de2b6%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-dev/85f9b89c-0f9e-425a-9681-dd9a7e2de2b6%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/
msgid/mongodb-dev/CAJBhJ-5rC6ontd-vYaQDnZNwZYOxNigwzSaHNa2Ja94Xy
PBeJg%40mail.gmail.com
<https://groups.google.com/d/msgid/mongodb-dev/CAJBhJ-5rC6ontd-vYaQDnZNwZYOxNigwzSaHNa2Ja94XyPBeJg%40mail.gmail.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/CAHnCjA0zO%2By_40FjGW9ZWj5sM4OOv%2BM4K_rapw4F%2BF80aAS0Sg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Monika Shah
2018-03-23 06:32:21 UTC
Permalink
I have downloaded source from
https://github.com/mongodb/mongo/wiki/Build-Mongodb-From-Source.
and compiled using "scon MONGO_VERSION=3.4.5 --dbg=on --opt=off mongod
mongo"

After that, when I tried to debug using gdb "gdb ./mongod", it shows me
error segmentation falut
and no output when "sudo gdb ./mongod"

Please help me to resolve this debug error
Post by 'Eric Milkie' via mongodb-dev
Hi Ricardo,
I've had good luck setting breakpoints using the filename/line number
br myfile.cpp:155
-Eric
On Fri, Jan 20, 2017 at 9:09 AM, Ricardo Amendoeira <
Post by Ricardo Amendoeira
PS: So I have been trying with gdb to see if it would help. It does show
me the threads that exist and allows me to switch between them but I can't
find a way to add breakpoints to a function in an anonymous namespace or by
file name.
gdb also makes it hard to read the code and get context, if it's the only
option that's ok but if someone knows of a nice alternative, please tell me
:)
I'm sorry if these questions are somewhat annoying, I'm not experienced
with C++ but I have used C for a while.
Thanks :)
--
You received this message because you are subscribed to the Google Groups
"mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an
<javascript:>.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit
https://groups.google.com/d/msgid/mongodb-dev/85f9b89c-0f9e-425a-9681-dd9a7e2de2b6%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-dev/85f9b89c-0f9e-425a-9681-dd9a7e2de2b6%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/1f921a16-2d29-4a5f-9c4f-7b27618eeaf6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Monika Shah
2018-03-24 12:17:54 UTC
Permalink
Thank you all. Suddenly it is working now just with sudo gdb ./mongod.

There are many cpp files . From name, we can get some idea. But, it is
complex and time consuming.
Can you help me now to see query processing / optimization flow?
Post by Monika Shah
I have downloaded source from
https://github.com/mongodb/mongo/wiki/Build-Mongodb-From-Source.
and compiled using "scon MONGO_VERSION=3.4.5 --dbg=on --opt=off mongod
mongo"
After that, when I tried to debug using gdb "gdb ./mongod", it shows me
error segmentation falut
and no output when "sudo gdb ./mongod"
Please help me to resolve this debug error
Post by 'Eric Milkie' via mongodb-dev
Hi Ricardo,
I've had good luck setting breakpoints using the filename/line number
br myfile.cpp:155
-Eric
On Fri, Jan 20, 2017 at 9:09 AM, Ricardo Amendoeira <
Post by Ricardo Amendoeira
PS: So I have been trying with gdb to see if it would help. It does show
me the threads that exist and allows me to switch between them but I can't
find a way to add breakpoints to a function in an anonymous namespace or by
file name.
gdb also makes it hard to read the code and get context, if it's the
only option that's ok but if someone knows of a nice alternative, please
tell me :)
I'm sorry if these questions are somewhat annoying, I'm not experienced
with C++ but I have used C for a while.
Thanks :)
--
You received this message because you are subscribed to the Google
Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit
https://groups.google.com/d/msgid/mongodb-dev/85f9b89c-0f9e-425a-9681-dd9a7e2de2b6%40googlegroups.com
<https://groups.google.com/d/msgid/mongodb-dev/85f9b89c-0f9e-425a-9681-dd9a7e2de2b6%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/e9506477-487d-4835-9e70-5933de313926%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ricardo Amendoeira
2017-01-25 18:25:23 UTC
Permalink
Thank you both :)

I was very inexperienced with gdb so that was holding me back as well.
Thanks Eric, indeed setting by file name works fine, I must have been doing
something wrong,
And thanks Mathias, the integration is really nice! :)
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/9fd28008-2abf-475f-a050-acf43b3c5221%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Monika Shah
2018-03-20 15:59:54 UTC
Permalink
Hi,

I would like to see process of plan selection and few other logic.
Can you help me for how and where to set option to trace the code?

On Wednesday, January 25, 2017 at 11:55:23 PM UTC+5:30, Ricardo Amendoeira
Post by Ricardo Amendoeira
Thank you both :)
I was very inexperienced with gdb so that was holding me back as well.
Thanks Eric, indeed setting by file name works fine, I must have been
doing something wrong,
And thanks Mathias, the integration is really nice! :)
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/4f951d7d-613c-438b-b4de-5bd4cf2942f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Monika Shah
2018-03-21 16:25:40 UTC
Permalink
Hello sir,

I request you to give detailed steps to debug mongod source to understand
query processing and meta data.

On Friday, January 20, 2017 at 4:20:21 PM UTC+5:30, Ricardo Amendoeira
Post by Ricardo Amendoeira
Hello,
I want to implement a new type of sharding (by 2dsphere coordinates) to
MongoDB as part of my thesis.
I'm having a really hard time with debugging on Linux.
I have compiled mongo, mongod and mongos with the --dbg=on and --opt=off
options, I run Nemiver (a gdb frontend) with the mongos from
build/debug/mongo, with the working directory build/debug/mongo.
When I set my breakpoints they do stop the program execution but I can't
see local variables (other than some local variable called 'indexes' which
seems useless to me) and when I click next it often complains that it can't
find a source file (the file it looks for seems to be a temporary file
created during the build process, which indeed does not exist) and jumps to
assembly.
I think part of my problem is that mongos has more than one thread, is
there a way to compile it to use a single thread?
The issue regarding the missing source file I'm not sure what it could be,
any ideas?
What best practices are there for debugging mongodb and what tools do you
recommend?
Thank you :)
--
You received this message because you are subscribed to the Google Groups "mongodb-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-dev+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at https://groups.google.com/group/mongodb-dev.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-dev/0dd13df9-3c2b-401e-b32f-4630d819129b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...