Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] General API to retreive a Memory Block from different targets

Hi Jonah,

 

Thanks again for your answer, I will probably try to reach out to the TCF community to get help.

 

I tried to use the Eclipse Platform Debug APIs, but I cannot successfully use it. I might have to duplicate some specific portion of my code to be able to support both TCF and GDB server.

 

Thank you so much for the help that you provided.

 

Alexis

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Jonah Graham
Sent: November 23, 2020 11:38 AM
To: CDT General developers list.
Subject: Re: [cdt-dev] General API to retreive a Memory Block from different targets

 

Hi Alexis,

 

I am pleased that you got some memory reading based on the info I provided you. Sorry it didn't end up being exactly what you were looking for. TCF does use some of DSF, but I am not really that familiar with it, the TCF maintainer is pretty responsive, so you can try reaching out on that mailing list: https://accounts.eclipse.org/mailing-list/tcf-dev I am subscribed there too, so I may be able to join in on the conversation if it helps fill in any gaps.

 

The Eclipse Platform Debug has IMemoryBlock and related interfaces and classes. I don't really know if that is the correct thing for your use case, but CDT provides memory contents to the memory view with that interface, so it seems likely useful if TCF also does. Not sure of the starting point, but I would guess looking at DebugPlugin.getDefault().getMemoryBlockManager() would be a logical place? 

 

HTH,

Jonah

 

 

 


~~~
Jonah Graham
Kichwa Coders
www.kichwacoders.com

 

 

On Mon, 23 Nov 2020 at 07:44, Alexis Bouffies <Alexis.Bouffies@xxxxxx> wrote:

Hi Jonah,

 

Thanks a lot for your answers. The DSF tutorials helped me to understand the concepts of DSF. I finally end up with something that works: for a remote GDB server (e.g, in Qemu) I am able to retrieve a memory block with a specific start address and size.

 

As my code needed to be synchronous I indeed used a Query. Your pointers were really helpful.

 

However, In the process I realized that TCF is not using DSF. I found some documentation about a project that try to connect DSF and CDT but it seems deprecated. To avoid duplication of code I wonder if I should use the Eclipse Platform Debug APis directly, or something in CDT. Because right now I cannot use DMContexts from DSF as TCF implements its own mechanism. Do you have an idea what I could look at?

 

Thanks again,

Alexis

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Jonah Graham
Sent: November 19, 2020 9:59 AM
To: CDT General developers list.
Subject: Re: [cdt-dev] General API to retreive a Memory Block from different targets

 

Hi Alexis,

 

The DSF asynchronous model is somewhat unique. You are on the correct track - but you shouldn't be creating the services yourself, but instead obtaining them from the service tracker. To learn DSF programming model have a look at the DSF tutorial at https://help.eclipse.org/2020-09/topic/org.eclipse.cdt.doc.isv/guide/dsf/intro/dsf_programming_intro.html?cp=15_0_6

 

The IMemoryDMContext can't generally be retrieved with an adapter call. Use DMContexts.getAncestorOfType. For example if your dmc is a frame context (most common type of selection in the Debug view) then it's parent is an execution context representing a thread, and its parent is a container context representing a process. In the standard gdb use case, the container ancestor is also a memory context (because each process has its own view of memory).

 

So, something like IMemoryDMContext memContext = DMContexts.getAncestorOfType(dmc, IMemoryDMContext.class).

 

Then you can use the executor that you obtained (your exec variable) to execute async operations on the memory service you have obtained from the service tracker (don't forget to dispose it) that you can create like this: tracker = new DsfServicesTracker(YOURPLUGIN.getBundleContext(), session.getId()); 

 

If your calling code needs to be synchronous you can run your operation in a Query - but be careful of concurrency rules in the link.

 

I hope that has been helpful. Please ask follow up questions. DSF is very powerful, but also quite complicated to go with that power.

 

Jonah

 

 

 

 

 


~~~
Jonah Graham
Kichwa Coders
www.kichwacoders.com

 

 

On Thu, 19 Nov 2020 at 09:24, Alexis Bouffies <Alexis.Bouffies@xxxxxx> wrote:

Hi Jonah,

 

Thanks a lot for your answer. I took a look at the IMemory service and I feel it is what I need.

 

I started to implement a solution, but I probably do something wrong. My code is the following:

 

IAdaptable context = DebugUITools.getDebugContext();

IDMContext dmc = context.getAdapter(IDMContext.class);

IMemoryDMContext memContext = context.getAdapter(IMemoryDMContext.class);

DsfSession mi = DsfSession.getSession(dmc.getSessionId());

Executor exec = mi.getExecutor();

DataRequestMonitor<MemoryByte[]> drm = new DataRequestMonitor<MemoryByte[]>(exec, null);

                               

GDBMemory gdbMem =  new GDBMemory(mi);

                               

gdbMem.getMemory(memContext, address, offset, word_size, count, drm);

 

It seems that my memContext variable is always null. I cannot find any other way to get the memory context. However I am not 100% sure I am going into the right direction.

 

Any help would be greatly appreciated.

 

Best regards,

Alexis

 

From: cdt-dev-bounces@xxxxxxxxxxx [mailto:cdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Jonah Graham
Sent: November 17, 2020 8:46 PM
To: CDT General developers list.
Subject: Re: [cdt-dev] General API to retreive a Memory Block from different targets

 

Hi Alexis,

 

I suspect you are looking for the IMemory DSF service (org.eclipse.cdt.dsf.debug.service.IMemory) or one of its sub-interface services (like IGDBMemory or IGDBMemory2). I don't know which of those services TCF uses.

 

The IMemory service provides methods like getMemory, setMemory and fillMemory as well as methods to query items such as addressable size, and events such as memory changed events.

 

HTH,

Jonah


~~~
Jonah Graham
Kichwa Coders
www.kichwacoders.com

 

 

On Tue, 17 Nov 2020 at 16:11, Alexis Bouffies <Alexis.Bouffies@xxxxxx> wrote:

Hi all,

 

I'm trying to use DSF to handle the debugging aspects of my custom C/C++ developer RCP.

 

I would like to develop a plug-in that would allow to extract information from a debugging session independently from the source: for instance I could debug either using a debugger that rely on the TCF protocol, or using a GDB server on target. I noticed that both those “debug options” possess a CDT DSF extension available.

 

One of my use case is to extract a Memory Block during a debug session, without having to duplicate any code for one or the other debug option. I searched for a common API in the Eclipse platform and in the CDT source code, but so far I was not able to find any leads. I am using CDT 9.8 in Eclipse 2019-06.

 

Best regards and thanks in advance,

Alexis

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev

_______________________________________________
cdt-dev mailing list
cdt-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdt-dev


Back to the top