Draw diagram by call stack - visual-studio-2010

Does any one know how to draw a class diagram by call stack in VS2010?

As rerun said, the question in itself doesn't make much sense, perhaps you mean a Sequence Diagram? If so, you can't directly create it from the CallStack window, but you can create it from the code editor as described here.

The closest built-in thing to what you want is the Parallel Stacks debug window, which can be accessed via the Debug menu, Windows menu.
It doesn't exactly give you a seperate box for each item in the call chain, but at least it's visual and easier to visually parse than the call stack window.
Be sure to turn on the Method View.
It also allows navigation to the methods in the call stack.

Related

How to break code on a click event?

I have this application that I need to disassemble. I don't have a clue on how to stop the running code on the desired location, so I decided my best guess would be breaking upon a button click. But how do I capture button clicks? I know it has probably something to do with the Windows functions such as CallNextHookEx. I'm using IDA PRO to disassembly.
IDA PRO is used mostly as disassembler, for static analysis purposes. I'd suggest you to use Ollydbg (or some other debugger, if you want to) because it will suit better to debugging purposes.
I don't know if you can set a breakpoint on an API like that.
But you can do this:
Load the application in olly, or attach to it.
Generate the event by clicking on anything.
Stop the application from ollydbg(F12)
Use C(k)all stack(ALT+K)
You will see a few calls to functions, one of them is doing what you need. But you may need to go to upper calls to see the whole loop. So you will just try which one it is. There will be a loop in one of them.That loop will have conditional jumps and generate events, load forms, fill the app etc. And when you place a breakpoint on the right jump there, it will stop at each mouse click.
When I'm debugging apps, most of the times I find myself on a breakpoint like this, and I see from the beginning how the application is filling an empty form(it takes so long.)

How can I know who calls the method in Xcode?

Does Xcode have a way to show the caller function of a method? I want to know all of the calling functions of a method in a class. A solution would be to find the method in the project, but sometimes different classes have methods with the same name - That could find us a method we're not looking for..
Many other IDEs have this capability, such as Visual C++ 2003/2005/2008,Eclipse ...
Can you do this in XCode?
Xcode 4.4 intrudced this functionality:
New Features in Xcode 4.4 (Scroll down to 'Find and Search Additions')
Move your cursor on top of the function you are interested in
Open the Assistant editor(⌃ +⌘+Enter)
On the top of the assistant editor, Select 'Callers'
You will see a list of all the function that's calling your function
Not the as effective as other IDEs, but does the job.
Yes. Set a breakpoint inside your method, then when it breaks, there are two spots to see a stack. First is in Xcode's "console" area (usually the bottom middle), there is a top-bar which may not immediately appear to be navigable, but it is a select-style UI control which has the entire stack in it. Selecting a different level shows you that scope's variables, etc. and pops your editor to that exact file (where you can mouse-over variables to see their in-memory real-time values). Second is in the left-hand area (where you normally browse files). There is another tab there (besides the file browser) for exactly this purpose. There is a slider at the bottom which controls how many "steps" in the stack you see; clicking on one has a similar affect.
For simple refactoring such as method re-naming, you can use the contextual-menu when you right-click a selected method-name, and Xcode will replace all identical selectors in your project. However, this does not address what you mentioned about different classes having methods with the same signature. It does, however, give you a very nice interface for reviewing the changes in-context and easily accepting or rejecting them one at a time.
It might be noted, however, that changing method signatures often may be a sign of poor design, and particularly if you have to do it with methods which have the same signature on different classes (which are not "siblings" and therefore should both get the rename)

MFC 10 - Is it possible to have a CFrameWnd within a CView?

I'm using MFC (yes must be MFC and no I can't interop with .Net) to create a CFrameWnd.
My goal is to create a CFrameWnd containing a CFormView which is based on a Dialog Template that resembles something like:
I have got the frame and view to display, and I have an Edit control on there. Now what I want is to have a CToolbar aligned to the top of the Edit Text control but not docked to the top frame.
Ideally I would like to have a child frame/view that I can dynamically add in place of the Statement Group. That way I could just dock the toolbar as normal.
The thing that I find odd is that I could easily achieve this if I had a splitter in there by using the CreateView function. I really don't want to have a splitter and feel there ought to be another way.
In summary, these are the question I need help with:
Q1 - How can I have a CFrameWnd within a CView (like what CSplitter::CreateView does)?
Q2 - How can I position a toolbar within a CView without docking or floating it within another frame (I'm more than willing to resize, position it manually if only I knew how)?
Now I really appreciate how easy things are in .Net.
I wouldn't recommend sticking a CFrameWnd within a CView. You'll be fighting MFC all the way, basically living in a world of ASSERTs as the internal functionality such as message routing assumes that Frames don't live in views.
Instead just use a CWnd instead of the CFrameWnd and in the 'Create' method manually create the toolbar and the edit ctrl and size and position them yourself (create a AdjustLayout method that uses CMFCToolbar::CalcFixedLayout to adjust the position of your other components).
A great example of this is in the Visual Studio sample app PropertiesViewBar.cpp:
http://msdn.microsoft.com/en-us/library/bb983983(v=vs.90).aspx
Note: You might need to override OnCmdMsg to extend the message routing to the internal controls.

chrome-like status bar in qt

I'm not big on creating GUI's, and generally my philosophy is: I don't create them, or I make them as simple as possible (and convince myself that it's better for usability :)
For my current project, I'm using Qt from Python (PyQt), and I want to start adding some GUI elements without cluttering the interface.
My idea is to create these elements as sort of floating-shaped-widgets that only appear when necessary; pretty much like the status bar (and find bar) in chrome.
Is there any standard api that enables creating this kind of interface?
This is not very complicated. If you want something like the status bar in Chrome you just need to have a QFrame at the bottom of your windows and show or hide it when you need it.
You have 2 options here, add is as part of your window layout so all the items move up when it is shown. Or you can have if floating, so it will be shown on top of the items. For the second option you need to create the QFrame with the window as parent and then in the window resizeEvent set the geometry of the frame.
This is an example of the second approach:
void MyWindow::resizeEvent(QResizeEvent* event)
{
frame.setGeometry(0, this->height() - frame.sizeHint().height(), this->width(), frame.sizeHint().height());
}
I hope this helps.

How can I trace what happens during XAML loading?

I would like to find a way to see what happens while my XAML is being loaded. What classes are being instantiated, and in what order? Which properties are being set, to what values, and in what order? Which methods are being called (e.g. BeginInit, EndInit, etc.), in what order, and with what parameters? That sort of thing.
(If anyone's curious as to why, it's because the XAML loader is doing something magic that I can't duplicate in code, and I'm trying to figure out what it is.)
My first idea: Configure VS to debug into the .NET source code, and single-step through the XAML-loading code to see what happens. Unfortunately, source stepping has been busted for months, and there's no sign of that changing.
My second idea: Make my own classes that descend from WPF classes, override OnPropertyChanged, and do a Debug.WriteLine. Unfortunately, one of the classes I want to know about (BitmapImage) is sealed, so I can't descend from it.
Anyone have other ideas on how I could get some visibility into what the XAML loader is doing? Are there any tools (profiler, maybe?) that could give me a call graph? Is there a way to turn on some kind of logging in the XAML loader? Thoughts / suggestions?
Edit: The article Steve linked to does have the answer, though their sample code makes every event get displayed twice. For reference, here's how to make this work in code (no app.config changes required). Add these lines before the InitializeComponent() call (or type both lines into the Immediate window in the debugger):
PresentationTraceSources.Refresh();
PresentationTraceSources.MarkupSource.Switch.Level = SourceLevels.All;
This will cause detailed output to show up in VS's Output window, including the properties that get set magically behind the scenes.
You can trace a lot of the binding and loading with system.diagnostics. I've found a number of problems using this namespace. Its unwieldy like everything else in WPF, but it works. You can see what's getting set and where.

Resources