How to set a breakpoint in code from referenced .dll? - visual-studio-2010

I am trying to set a breakpoint on a method from library System.Web.Mvc:
Microsoft.Web.Mvc.Html.HtmlHelperExtensions.EditorFor
The symbols are loaded. But how can I set a breakpoint if I can't open source code? I've tried "Debug > New Breakpoing > Break at Function" with
Microsoft.Web.Mvc.Html.HtmlHelperExtensions.EditorFor
but no luck.

Related

Goland ssh debug mode fail: executable doesn't containt debug information

I use Goland ssh to write code. I fail to use debug mode in my project, the breakpoints turn into gray crossed circles and report error "executable doesn't containt debug information".
The error information is here.
This is the Run/Debug Configuration of my project
However, I still could use debug mode and set normal breakpoints in Testing file.
I met exactly the same problem just now.
Finally I find the reason is the function which I set breakpoint doesn't been called in the repo.
It's called by another repo, so compile and debug the repo that call this function can solve this problem.
The error "error layer=debugger error loading binary "/lib/x86_64-linux-gnu/libpthread.so.0": could not parse .eh_frame section: pointer encoding not supported 0x9b at 0x12e8" still exists, but the breakpoints won't turn into gray crossed circles.
please see this https://youtrack.jetbrains.com/issue/GO-13005 .
Next 2022.2 nightly build bundles delve which doesn't produce an error.

How to break on gdk_x_error() using gdb?

My problem is the following: An application (namely eclipse) crashes on my machine, and shows the following error message:
The error was 'BadWindow (invalid Window parameter)'.
(Details: serial 16911 error_code 3 request_code 3 minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error() function.)
Now what I want to do is to actually run gdb as suggested by the error message. However, I didn't succeed and no backtrace is displayed.
I haven't much experiences with debugging. Here is what I tried anyway:
1) Activate -dbgsym repositories
2) Install eclipse dbg symbols (command sudo apt-get install ^eclipse-.*dbgsym)
3) Install libgtk-3-0-dbg, libgtk2.0-0-dbg and all packages matched by ^libgdk.*dbg
4) Run gdb:
(gdb) file /usr/lib/eclipse/eclipse
Reading symbols from /usr/lib/eclipse/eclipse...
Reading symbols from /usr/lib/debug/.build-
id/c2/8e5f4ebdd67159093d8ee6e6daf58ab6fab94c.debug...done.
done.
(gdb) break gdk_x_error
Function "gdk_x_error" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
(gdb) run --sync
[Update] I also tried the following (without success):
1) - 3) same as above
4) Run gdb:
(gdb) file /usr/lib/eclipse/eclipse
Reading symbols from /usr/lib/eclipse/eclipse...
Reading symbols from /usr/lib/debug/.build-
id/c2/8e5f4ebdd67159093d8ee6e6daf58ab6fab94c.debug...done.
done.
(gdb) break main
Breakpoint 1 at 0x4010a0: file ../eclipseMain.c, line 101.
(gdb) run --sync
Starting program: /usr/lib/eclipse/eclipse --sync
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, main (argc=2, argv=0x7fffffffdf18) at ../eclipseMain.c:101
101 ../eclipseMain.c: file or directory not found.
(gdb) break gdk_x_error
Function "gdk_x_error" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
(gdb) cont
[/Update]
Result:
When the application crashes, the output is the same as above, no additional info is displayed. I assume that my approach is wrong, or I've loaded the wrong debug symbols. (Because it says "gdk_x_error" not defined.)
[Update2]
When I type bt after the crash, it shows me No Stack.
[/Update2]
What can I do to get a meaningful backtrace? Any ideas?

Why can breakpoints not be set in some file while other files are OK?

I'm debugging a project with WinDBG. I run across a weird problem:
Say the driver image is named foo.sys, and there are two source files named
src_1.c and src_2.c; there is a function named void f(); in src_2.c.
Step 1:
I use OSRLoader to load foo.sys into kernel successfully.
Step 2:
I use command lm to check if the symbol has been correctly loaded
kd> lm
...
...
8bad3000 8baec400 foo (private pdb symbols) d:\symbols\private\foo.pdb
...
...
and use command !itoldyouso ti verify
kd> !itoldyouso foo d:\symbols\private\foo.pdb
foo.sys
Timestamp: 526DC759
SizeOfImage: 19400
pdb: f:\projects\foo\objchk_wxp_x86\i386\foo.pdb
pdb sig: 851C2562-6FE3-4391-88C6-320253CC3372
age: 1
foo.pdb
pdb sig: 851C2562-6FE3-4391-88C6-320253CC3372
age: 1
That proves the symbol has been correctly loaded.
Step 3:
I can set breakpoints in src_1.c at any valid code line.
Step 4:
I CANNOT set any breakpoints in src_2.c, even if I close and reload src_2.c
from the correct location. However, if I use bu foo!f to set a breakpoint on f,
it works.
After I have set a breakpoint on foo!f, the execution will be broken at foo!f as
expected, and I can do source-level debugging step-by-step.
However, even I can do source-level debugging step-by-step in src_2.c, I still
cannot set any breakpoint in src_2.c through pressing F9.
What's the root cause?
Thanks.

compile option for rcpp and lib files in windows

Hi I am trying to work with the rcpp. For this I want some cpp code which loads a dll by use of a lib-file (which has the same name as ). the code which I let run is:
cppFunction(includes=c("#include "windef.h","#include \"C:/data/Rdata/IHUAPI.H\" "), 'int functietom(int a){long serverhandle;int lRet;lRet = ihuConnect ( "historian1",NULL,NULL, &serverhandle ); return 5;}', verbose
= TRUE)
I get the following error:
undefined reference to `ihuConnect#16' collect2: ld returned 1 exit
status Error in inDL(x, as.logical(local), as.logical(now), ...) :
unable to load shared object
'C:/Users/user1663/AppData/Local/Temp/RtmpSW1Ki7/sourcecpp_1a04df63309/sourceCpp_26588.dll':
LoadLibrary failure:
the ihuConnect function is located in the ihuapi.lib and ihuape.dll files. In c++ in visual studio I add the lib file as added dependency and then I get rid of this error because I also sometimes get this error and then it was that I forgot to add the lib file in the compilation.
Thus My question is: how can I add this lib file as option in the compilation.
when I use dyn.load
("C:/data/Rdata/ihUAPI.dll")
and then check if it is loaded then he says yes
the problem is that getDLLRegisteredRoutines('ihUAPI', addNames = TRUE)
then it says:
data frame with 0 columns and 0 rows
so the dll seems not to contain the functions but it does when I use it from visual studio.
So please some help with lib-files and ddl-files
Tom Wambecq
You missed the Rcpp FAQ entry 2.9 'Can I use Rcpp with Visual Studio ?'.
And to kill all the suspense: No, you cannot.

Code::Blocks debugger shows some other path which isn't included in the project

I'm trying to use code::blocks debugger. I followed this basic tutorial on how to do it. I also watched two videos on you tube. I was actually trying it on a bigger file which had its declaration & implementation in separate files (one was header file tree.h, one had its implementation tree.cpp & the last one had implementation_tree.cpp main function to check the header file) but it didn't work so I tried it on a very simple program. But now debugger shows this error
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: F:\Coding\test\test\
Adding source dir: F:\Coding\test\test\
Adding file: F:\Coding\test\test\bin\Debug\test.exe
Changing directory to: F:/Coding/test/test/.
Set variable: PATH=.;C:\Program Files\CodeBlocks\bin;C:\Program Files\CodeBlocks;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0
[debug]Command-line: F:\Coding\Data Structures\tree.h -nx -fullname -quiet -args F:/Coding/test/test/bin/Debug/test.exe
[debug]Working dir : F:\Coding\test\test
Starting debugger: F:\Coding\Data Structures\tree.h -nx -fullname -quiet -args F:/Coding/test/test/bin/Debug/test.exe
failed
Whatever is in this line [debug]Command-line: is the address of my tree.h file which I was trying to debug earlier. But now I've removed all the breakpoints & everything related to that file from Code::Blocks & even changed that file's location but it still shows that same address in Starting debugger:. I've also rebuilt my test program after deleting everything related to it several times but I'm still getting the same error. I'm using GDB.
I'm so sorry if this question sounds very silly as I'm trying this for the first time & not being able to proceed through any tutorials or any other forum or anything else. I've also seen other related questions on stackoverflow but none of them works for me. So, please help. Thanks.
Settings -> Compiler -> Search Directories.. Delete all paths from there.

Resources