CANoe CAPL function: clear trace window - canoe

I'm currently trying to find a way to automate the clearing of the trace window in CANoe.
I've had a look on the help menu within CANoe but there's nothing apart from a manual x option available on the Trace window itself. Does anyone have any ideas?

Syntax
void traceWindowClear(char[] windowName);
Function
Clears the contents of the Trace Window.
Parameters
windowName - The name of the Trace Window.
Return Values
—
Availability
Since Version 11.0 In Measurement Setup and Simulation / Test Setup.

Related

How does mock-debugger control which line the debugger steps next?

I'm unable to understand how the mock-debugger extension controls where the next step is.
For example what if I'd like to step 2 lines if I find the word "banana" in my text? Also, I'd like to do something, like "Step In", where I can walk word-by-word - is it possible?
I've seen the this._currentLine = ln; assign, which looks like it controls where the line is, but it's just a simple local variable. How could it ever control anything in the debugger? I can't find any other uses of the _currentLine varbiable where it passes to anything useful API (except for stack tracing, but I don't think it has any relation with the debugger line-control).
The stack trace is the only source for the debugger step visualization. When the debugger gets a notification to pause it requests the current stack trace. The TOS determines where the next execution point will be located. Hence the debug adapter is reponsible to determine this position precisely.

how to edit simulink plutosdr qpsk example

I am working with this example from MathWorks: https://www.mathworks.com/help/supportpkg/plutoradio/examples/qpsk-transmitter-with-adalm-pluto-radio-1.html
When i run the example it creates an sdrqpsktx variable in the matlab workspace
I want to change sdrqpsktx.MessageBits to something smaller.
When i run the following code in matlab:
a = sdrqpsktx.MessageBits(1:448);
sdrqpsktx.MessageBits = a;
I successfully change sdrqpsktx.MessageBits to a.
However when i run this in simulink sdrqpsktx.MessageBits changes back to its original size.
How do i permanently change sdrqpsktx.MessageBits and run the example with my changes?
Thank you.
There is a model callback, probably a StartFcn, that is overwriting your changes to the variable every time you start the simulation. You either need to delete or modify that code.
To see the code go to:
File->Model Properties->Model Properties, and select the Callback tab.
Any callback that is followed by a * has code in it. Click on that callback to see the code.
See Callbacks for Customized Models for more detailed information.

Can I disable the "Unable to read dynamic function table entry" message in WinDbg?

I'm working with a program that generates a lot of code at runtime, and seems not to produce any unwind data for it. (I don't have source code for this program; I'm writing a plugin for it.)
When the program hangs, I break into it with WinDbg, and try to get a stack trace for all threads with ~* k. As well as the stack traces, I also get pages and pages (and pages, and more) of messages along the line of
Unable to read dynamic function table entry at 00000000`2450b580
This takes a long time to print - over a minute - and it overflows the scroll buffer, so I lose most of the output.
I've worked around this for now by hex-editing the DLL that contains this message, but... seriously. Is there an official way of getting rid of this message?
I'm prepared for a crappy stack trace from the problem thread(s).
Note that this is a security feature, so disable it at your own risk. There are two options:
If you know which module is causing this, you can add the full path to the register: HKLM\Software\Microsoft\Windows NT\CurrentVersion\KnownFunctionTableDlls registry key
You can disable it with .settings set EngineInitialization.VerifyFunctionTableCallbacks=false
The second option only disables it for the current session. If you want to make it permanent, you can follow it with .settings save.
if you are running the latest versions of windbg
you can try setting the Engine Initialization Settings
0:000> dx Debugger.Settings.EngineInitialization.VerifyFunctionTableCallbacks
Debugger.Settings.EngineInitialization.VerifyFunctionTableCallbacks : true
0:000> dx Debugger.Settings.EngineInitialization.VerifyFunctionTableCallbacks = false
Debugger.Settings.EngineInitialization.VerifyFunctionTableCallbacks = false : false
0:000> dx Debugger.Settings.EngineInitialization.VerifyFunctionTableCallbacks
Debugger.Settings.EngineInitialization.VerifyFunctionTableCallbacks : false

application creating muant handles and never frees them

My c++ application is creating mutant handles. I couldn't find where the handle is being created, so I used Windbg and with !htrace. It doesnt give the exact function name. All my symbol files are loaded and the application is built in debug mode.
!htrace shows open handles but the exact function where the handle is been opened,it doesnt show.
The trace looks like this
Handle = 0x00000d34 - OPEN
Thread ID = 0x00003670, Process ID = 0x00004748
0x77a0473c: ntdll!ZwCreateMutant+0x0000000c
0x75d7a0cd: KERNELBASE!CreateMutexExW+0x0000005e
0x75d7bb94: KERNELBASE!CreateMutexExA+0x0000002f
0x75d7bb5c: KERNELBASE!CreateMutexA+0x0000001d
Is there any alternative way to debug this issue?

Output to command-line if started from command line

I'm writing an application that can be started either as a standard WinForms app or in unattended mode from the command-line. The application was built using the VS 2k5 standard WinForms template.
When the application is executed from the command-line, I want it to output information that can be captured by the script executing the application. When I do this directly from Console.WriteLine(), the output does not appear, although it can be captured by piping to a file.
On the other hand, I can force the application to pop up a second console by doing a P/Invoke on AllocConsole() from kernel32. This is not what I want, though. I want the output to appear in the same window the application was called from.
This is the salient code that allows me to pop up a console from the command line:
<STAThread()> Public Shared Sub Main()
If My.Application.CommandLineArgs.Count = 0 Then
Dim frm As New ISECMMParamUtilForm()
frm.ShowDialog()
Else
Try
ConsoleControl.AllocConsole()
Dim exMan As New UnattendedExecutionManager(ConvertArgs())
IsInConsoleMode = True
OutputMessage("Application started.")
If Not exMan.SetSettings() Then
OutputMessage("Execution failed.")
End If
Catch ex As Exception
Console.WriteLine(ex.ToString())
Finally
ConsoleControl.FreeConsole()
End Try
End If
End Sub
Public Shared Sub OutputMessage(ByVal msg As String, Optional ByVal isError As Boolean = False)
Trace.WriteLine(msg)
If IsInConsoleMode Then
Console.WriteLine(msg)
End If
If isError Then
EventLog.WriteEntry("ISE CMM Param Util", msg, EventLogEntryType.Error)
Else
EventLog.WriteEntry("ISE CMM Param Util", msg, EventLogEntryType.Information)
End If
End Sub
Raymond Chen recently posted (a month after the question was posted here on SO) a short article about this:
How do I write a program that can be run either as a console or a GUI application?
You can't, but you can try to fake it.
Each PE application contains a field
in its header that specifies which
subsystem it was designed to run
under. You can say
IMAGE_SUBSYSTEM_WINDOWS_GUI to mark
yourself as a Windows GUI application,
or you can say
IMAGE_SUBSYSTEM_WINDOWS_CUI to say
that you are a console application. If
you are GUI application, then the
program will run without a console.
The subsystem determines how the
kernel prepares the execution
environment for the program. If the
program is marked as running in the
console subsystem, then the kernel
will connect the program's console to
the console of its parent, creating a
new console if the parent doesn't have
a console. (This is an incomplete
description, but the details aren't
relevant to the discussion.) On the
other hand, if the program is marked
as running as a GUI application, then
the kernel will run the program
without any console at all.
In that article he points to another by Junfeng Zhang that discusses how a couple of programs (Visual Studio and ildasm) implement this behavior:
How to make an application as both GUI and Console application?
In VisualStudio case, there are actually two binaries: devenv.com and devenv.exe. Devenv.com is a Console app. Devenv.exe is a GUI app. When you type devenv, because of the Win32 probing rule, devenv.com is executed. If there is no input, devenv.com launches devenv.exe, and exits itself. If there are inputs, devenv.com handles them as normal Console app.
In ildasm case, there is only one binary: ildasm.exe. It is first compiled as a GUI application. Later editbin.exe is used to mark it as console subsystem. In its main method it determines if it needs to be run as console mode or GUI mode. If need to run as GUI mode, it relaunches itself as a GUI app.
In the comments to Raymond Chen's article, laonianren has this to add to Junfeng Zhang's brief description of how Visual Studio works:
devenv.com is a general purpose console-mode stub application. When it runs it creates three pipes to redirect the console's stdin, stdout and stderr. It then finds its own name (usually devenv.com), replaces the ".com" with ".exe" and launches the new app (i.e. devenv.exe) using the read end of the stdin pipe and the write ends of the stdout and stderr pipes as the standard handles. Then it just sits and waits for devenv.exe to exit and copies data between the console and the pipes.
Thus even though devenv.exe is a gui app it can read and write the "parent" console using its standard handles.
And you could use devenv.com yourself for myapp.exe by renaming it to myapp.com. But you can't in practise because it belongs to MS.
Update 1:
As said in Michael Burr answer, Raymond Chen recently posted a short article about this. I am happy to see that my guess was not totally wrong.
Update 0:
Disclaimer: This "answer" is mostly speculation. I post it only because enough time has passed to establish that not many people have the answer to what look like a fundamental question.
I think that the "decision" if the application is gui or console is made at compile time and not at runtime. So if you compile your application as gui application, even if you don't display the gui, its still a gui application and doesn't have console. If you choose to compile it as console application then at minimum you will have a console windows flashing before moving to gui "mode". And I don't know if it is possible in managed code.
The problem is fundamental, I think, Because a console application has to take "control" of the calling console application. And it has to do so before the code of the child application is running.
If you want to check if your app is started from the command line in .NET, you can use Console.GetCursorPosition().
The reason that this works is that when you start it from the command line, the cursor moves away from the initial point ((0, 0)) because you typed something in the terminal (the name of the app).
You can do this with an equality check (code in C#):
class Program
{
public static void Main
{
if (Console.GetCursorPosition() == (0, 0))
{
//something GUI
}
else
{
//something not GUI
}
}
}
Note: You must set the output type to Console Application as other output types will make Console.GetCursorPosition() throw an exception.