menu: added new Keywords tag to .desktop files
[barry.git] / src / m_jvmdebug.cc
blobd9820d8dfbdf254667b82792d770899232529bec
1 ///
2 /// \file m_jvmdebug.cc
3 /// Mode class for the JVMDebug mode
4 ///
6 /*
7 Copyright (C) 2005-2013, Net Direct Inc. (http://www.netdirect.ca/)
8 Copyright (C) 2008-2009, Nicolas VIVIEN
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 See the GNU General Public License in the COPYING file at the
20 root directory of this project for more details.
23 #include "i18n.h"
24 #include "m_jvmdebug.h"
25 #include "data.h"
26 #include "protocol.h"
27 #include "protostructs.h"
28 #include "packet.h"
29 #include "endian.h"
30 #include "error.h"
31 #include "usbwrap.h"
32 #include "controller.h"
33 #include "cod.h"
34 #include <stdexcept>
35 #include <sstream>
36 #include <iomanip>
37 #include <vector>
38 #include <string.h>
39 #include <time.h>
40 #include <stdio.h>
41 #include "ios_state.h"
43 #include "debug.h"
45 using namespace std;
46 using namespace Barry::Protocol;
48 namespace Barry {
50 ///////////////////////////////////////////////////////////////////////////////
51 // JDModulesList class
53 void JVMModulesList::Parse(const Data &entry_packet)
55 uint32_t count = 0;
57 size_t size = entry_packet.GetSize();
59 while (count < size) {
60 uint16_t len = 0;
62 const unsigned char *ptr = (entry_packet.GetData() + count);
63 Protocol::JVMModulesEntry *e = (Protocol::JVMModulesEntry *) ptr;
65 len = SB_JVMMODULES_ENTRY_HEADER_SIZE + be_btohs(e->sizename);
66 if( (count + len) > size )
67 break;
69 JVMModulesEntry entry;
71 entry.Id = be_btohl(e->id);
72 entry.UniqueID = be_btohl(e->uniqueId);
73 (entry.Name).assign((char *) (ptr + SB_JVMMODULES_ENTRY_HEADER_SIZE), be_btohs(e->sizename));
75 push_back(entry);
77 count += len;
82 void JVMModulesList::Dump(std::ostream &os) const
84 ios_format_state state(os);
86 const_iterator i = begin(), e = end();
88 os << _(" ID ") << "|";
89 os << _(" UniqueID ") << "|";
90 os << _(" Module Name") << endl;
92 os << "------------+";
93 os << "------------+";
94 os << "-------------";
95 os << endl;
97 for( ; i != e; ++i ) {
98 (*i).Dump(os);
103 ///////////////////////////////////////////////////////////////////////////////
104 // JVMModulesEntry class
106 void JVMModulesEntry::Dump(std::ostream &os) const
108 ios_format_state state(os);
110 os << " 0x" << setfill('0') << setw(8) << hex << Id << " |";
111 os << " 0x" << setfill('0') << setw(8) << hex << UniqueID << " |";
112 os << " " << Name << endl;
116 ///////////////////////////////////////////////////////////////////////////////
117 // JVMThreadsList class
119 void JVMThreadsList::Parse(const Data &entry_packet)
121 uint32_t count = 0;
123 size_t size = entry_packet.GetSize();
125 while (count < size) {
126 uint16_t len = 0;
128 const unsigned char *ptr = (entry_packet.GetData() + count);
129 uint32_t *e = (uint32_t *) ptr;
131 len = sizeof(uint32_t);
132 if( (count + len) > size )
133 break;
135 JVMThreadsEntry entry;
137 entry.Id = be_btohl(*e);
139 push_back(entry);
141 count += len;
146 void JVMThreadsList::Dump(std::ostream &os) const
148 ios_format_state state(os);
150 const_iterator i = begin(), e = end();
152 os << _(" Thread ") << "|";
153 os << _(" Address ") << "|";
154 os << _(" Byte ") << "|";
155 os << _(" Unknown01 ") << "|";
156 os << _(" Unknown02 ") << "|";
157 os << _(" Unknown03 ") << "|";
158 os << _(" Unknown04 ") << "|";
159 os << _(" Unknown05 ") << "|";
160 os << _(" Unknown06 ") << "|";
162 os << "------------+";
163 os << "------------+";
164 os << "------+";
165 os << "------------+";
166 os << "------------+";
167 os << "------------+";
168 os << "------------+";
169 os << "------------+";
170 os << "-------------";
171 os << endl;
173 for(int k=0 ; i != e; ++i, k++ ) {
174 (*i).Dump(os, k);
179 void JVMThreadsEntry::Dump(std::ostream &os, int num) const
181 ios_format_state state(os);
183 os << " " << setfill(' ') << setw(8) << dec << num << " |";
184 os << " 0x" << setfill('0') << setw(8) << hex << (Id) << " |";
185 os << " 0x" << setfill('0') << setw(2) << hex << (Byte) << " |";
186 os << " 0x" << setfill('0') << setw(8) << hex << (Address) << " |";
187 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown01) << " |";
188 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown02) << " |";
189 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown03) << " |";
190 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown04) << " |";
191 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown05) << " |";
192 os << " 0x" << setfill('0') << setw(8) << hex << (Unknown06) << endl;
196 namespace Mode {
198 ///////////////////////////////////////////////////////////////////////////////
199 // JVMDebug Mode class
201 JVMDebug::JVMDebug(Controller &con)
202 : Mode(con, Controller::JVMDebug)
203 , m_Attached(false)
207 JVMDebug::~JVMDebug()
209 if( m_Attached )
210 Detach();
213 ///////////////////////////////////////////////////////////////////////////////
214 // protected members
217 ///////////////////////////////////////////////////////////////////////////////
218 // public API
220 void JVMDebug::OnOpen()
224 // FIXME - is this necessary? and if it is, wouldn't it be better
225 // in the m_jvmdebug mode class? I'm not convinced that applications
226 // should have to bother with socket-level details.
227 void JVMDebug::Close()
229 if( m_ModeSocket ) {
230 m_socket->Close();
231 m_socket.reset();
232 m_ModeSocket = 0;
237 // Attach
239 /// These commands are sent to prepare the debug communication.
240 /// Must be called at the start of a JVMDebug session.
242 void JVMDebug::Attach()
247 // Detach
249 /// Must be called at the end of a JVMDebug session. The JVM_GOODBYE
250 /// command is sent to the device.
252 void JVMDebug::Detach()
257 void JVMDebug::ThrowJVMError(const std::string &msg, uint16_t cmd)
259 std::ostringstream oss;
260 oss << msg << ": " << _("unexpected packet command code: ")
261 << "0x" << std::hex << (unsigned int) cmd;
262 throw Error(oss.str());
267 // Unknown 01 ???
269 void JVMDebug::Unknown01()
271 uint16_t expect = 0;
273 Data command(-1, 8), response;
274 JVMPacket packet(command, response);
276 // Send the command packet
277 packet.Unknown01();
278 m_socket->Packet(packet);
279 expect = packet.Size();
281 if (expect == 0)
282 return;
284 // Read the data stream
285 m_socket->Receive(response);
287 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
289 // Check the size read into the previous packet
290 if( expect != bytereceived ) {
291 ThrowJVMError(string("JVMDebug::Unknown01(): ") + _("byte count mismatch"), expect);
297 // Unknown 02 ???
299 void JVMDebug::Unknown02()
301 uint16_t expect = 0;
303 Data command(-1, 8), response;
304 JVMPacket packet(command, response);
306 // Send the command packet
307 packet.Unknown02();
308 m_socket->Packet(packet);
309 expect = packet.Size();
311 if (expect == 0)
312 return;
314 // Read the data stream
315 m_socket->Receive(response);
317 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
319 // Check the size read into the previous packet
320 if( expect != bytereceived ) {
321 ThrowJVMError(string("JVMDebug::Unknown02(): ") + _("byte count mismatch"), expect);
327 // Unknown 03 ???
329 void JVMDebug::Unknown03()
331 uint16_t expect = 0;
333 Data command(-1, 8), response;
334 JVMPacket packet(command, response);
336 // Send the command packet
337 packet.Unknown03();
338 m_socket->Packet(packet);
339 expect = packet.Size();
341 if (expect == 0)
342 return;
344 // Read the data stream
345 m_socket->Receive(response);
347 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
349 // Check the size read into the previous packet
350 if( expect != bytereceived ) {
351 ThrowJVMError(string("JVMDebug::Unknown03(): ") + _("byte count mismatch"), expect);
357 // Unknown 04 ???
359 void JVMDebug::Unknown04()
361 uint16_t expect = 0;
363 Data command(-1, 8), response;
364 JVMPacket packet(command, response);
366 // Send the command packet
367 packet.Unknown04();
368 m_socket->Packet(packet);
369 expect = packet.Size();
371 if (expect == 0)
372 return;
374 // Read the data stream
375 m_socket->Receive(response);
377 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
379 // Check the size read into the previous packet
380 if( expect != bytereceived ) {
381 ThrowJVMError(string("JVMDebug::Unknown04(): ") + _("byte count mismatch"), expect);
387 // Unknown 05 ???
389 void JVMDebug::Unknown05()
391 uint16_t expect = 0;
393 Data command(-1, 8), response;
394 JVMPacket packet(command, response);
396 // Send the command packet
397 packet.Unknown05();
398 m_socket->Packet(packet);
399 expect = packet.Size();
401 if (expect == 0)
402 return;
404 // Read the data stream
405 m_socket->Receive(response);
407 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
409 // Check the size read into the previous packet
410 if( expect != bytereceived ) {
411 ThrowJVMError(string("JVMDebug::Unknown05(): ") + _("byte count mismatch"), expect);
417 // Unknown 06 ???
419 void JVMDebug::Unknown06()
421 uint16_t expect = 0;
423 Data command(-1, 8), response;
424 JVMPacket packet(command, response);
426 // Send the command packet
427 packet.Unknown06();
428 m_socket->Packet(packet);
429 expect = packet.Size();
431 if (expect == 0)
432 return;
434 // Read the data stream
435 m_socket->Receive(response);
437 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
439 // Check the size read into the previous packet
440 if( expect != bytereceived ) {
441 ThrowJVMError(string("JVMDebug::Unknown06(): ") + _("byte count mismatch"), expect);
447 // Unknown 07 ???
449 void JVMDebug::Unknown07()
451 uint16_t expect = 0;
453 Data command(-1, 8), response;
454 JVMPacket packet(command, response);
456 // Send the command packet
457 packet.Unknown07();
458 m_socket->Packet(packet);
459 expect = packet.Size();
461 if (expect == 0)
462 return;
464 // Read the data stream
465 m_socket->Receive(response);
467 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
469 // Check the size read into the previous packet
470 if( expect != bytereceived ) {
471 ThrowJVMError(string("JVMDebug::Unknown07(): ") + _("byte count mismatch"), expect);
477 // Unknown 08 ???
479 void JVMDebug::Unknown08()
481 uint16_t expect = 0;
483 Data command(-1, 8), response;
484 JVMPacket packet(command, response);
486 // Send the command packet
487 packet.Unknown08();
488 m_socket->Packet(packet);
489 expect = packet.Size();
491 if (expect == 0)
492 return;
494 // Read the data stream
495 m_socket->Receive(response);
497 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
499 // Check the size read into the previous packet
500 if( expect != bytereceived ) {
501 ThrowJVMError(string("JVMDebug::Unknown08(): ") + _("byte count mismatch"), expect);
507 // Unknown 09 ???
509 void JVMDebug::Unknown09()
511 uint16_t expect = 0;
513 Data command(-1, 8), response;
514 JVMPacket packet(command, response);
516 // Send the command packet
517 packet.Unknown09();
518 m_socket->Packet(packet);
519 expect = packet.Size();
521 if (expect == 0)
522 return;
524 // Read the data stream
525 m_socket->Receive(response);
527 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
529 // Check the size read into the previous packet
530 if( expect != bytereceived ) {
531 ThrowJVMError(string("JVMDebug::Unknown09(): ") + _("byte count mismatch"), expect);
537 // Unknown 10 ???
539 void JVMDebug::Unknown10()
541 uint16_t expect = 0;
543 Data command(-1, 8), response;
544 JVMPacket packet(command, response);
546 // Send the command packet
547 packet.Unknown10();
548 m_socket->Packet(packet);
549 expect = packet.Size();
551 if (expect == 0)
552 return;
554 // Read the data stream
555 m_socket->Receive(response);
557 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
559 // Check the size read into the previous packet
560 if( expect != bytereceived ) {
561 ThrowJVMError(string("JVMDebug::Unknown10(): ") + _("byte count mismatch"), expect);
567 // Get Status
569 bool JVMDebug::GetStatus(int &status)
571 uint16_t expect = 0;
573 Data command(-1, 8), response;
574 JVMPacket packet(command, response);
576 // Send the command packet
577 packet.GetStatus();
579 m_socket->Packet(packet);
581 expect = packet.Size();
583 if (expect == 0)
584 return false;
586 // Read the data stream
587 m_socket->Receive(response);
589 MAKE_JVMPACKET(dpack, response);
591 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
593 // Check the size read into the previous packet
594 if( expect != bytereceived ) {
595 ThrowJVMError(string("JVMDebug::GetStatus():") + _("byte count mismatch"), expect);
598 // Make sure we have a header to read
599 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.status));
601 // Return status
602 status = dpack->u.status;
604 return true;
609 // Wait Status
611 bool JVMDebug::WaitStatus(int &status)
613 uint16_t expect = 0;
615 Data command(-1, 8), response;
616 JVMPacket packet(command, response);
618 // Prepare the command packet
619 packet.GetStatus();
621 try {
622 m_socket->Receive(packet.GetReceive(), 100);
623 } catch (Usb::Timeout &DEBUG_ONLY(to) ) {
624 return false;
627 expect = packet.Size();
629 if (expect == 0)
630 return false;
632 // Read the data stream
633 m_socket->Receive(response);
635 MAKE_JVMPACKET(dpack, response);
637 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
639 // Check the size read into the previous packet
640 if( expect != bytereceived ) {
641 ThrowJVMError(string("JVMDebug::WaitStatus():") + _("byte count mismatch"), expect);
644 // Make sure we have a header to read
645 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.status));
647 // Return status
648 status = dpack->u.status;
650 return true;
655 // Get Console Message
656 // Sample, display the output of System.out.println(...) and all JVM messages output
658 // Return the length message or -1 if message doesn't exit or is empty
660 int JVMDebug::GetConsoleMessage(std::string &message)
662 uint16_t expect = 0;
664 Data command(-1, 8), response;
665 JVMPacket packet(command, response);
667 // Send the command packet
668 packet.GetConsoleMessage();
670 m_socket->Packet(packet);
672 expect = packet.Size();
674 if (expect == 0)
675 return -1;
677 // Read the data stream
678 m_socket->Receive(response);
680 MAKE_JVMPACKET(dpack, response);
682 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
684 // Check the size read into the previous packet
685 if( expect != bytereceived ) {
686 ThrowJVMError(string("JVMDebug::GetConsoleMessage():") + _("byte count mismatch"), expect);
689 // Make sure we have a header to read
690 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.msglength));
692 // Length of message
693 uint16_t length = be_btohs(dpack->u.msglength);
695 if (length == 0)
696 return -1;
698 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.msglength) + length);
700 // Parse the ID of nextmodules
701 const unsigned char *ptr = (response.GetData() + SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.msglength));
703 message.assign((char *) ptr, length);
705 return length;
710 // Get list of Java modules
712 void JVMDebug::GetModulesList(JVMModulesList &mylist)
714 uint32_t size = 0;
715 uint32_t offset = 0;
716 uint16_t expect = 0;
718 Data command(-1, 8), response;
719 JVMPacket packet(command, response);
721 do {
722 // Send the command packet
723 packet.GetModulesList(offset);
725 m_socket->Packet(packet);
727 expect = packet.Size();
729 if (expect == 0)
730 break;
732 // Read the data stream
733 m_socket->Receive(response);
735 // MAKE_JVMPACKET(dpack, response); // unused
737 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
739 // Check the size read into the previous packet
740 if( expect != bytereceived ) {
741 ThrowJVMError(string("JVMDebug::GetModulesList():") + _("byte count mismatch"), expect);
744 // Make sure there's enough for packet header + module list
745 // header + 4 bytes of ID
746 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMMODULES_LIST_HEADER_SIZE + 4);
748 // Number of modules entries in the list
749 // (Valid, but unused variable... disabled to stop compiler
750 // warnings)
751 // uint32_t count = be_btohl(dpack->u.moduleslist.nbr);
753 // Size of modules list
754 // I remove the header of packet (contains the field 'number of modules')
755 // and 4 bytes (contains the field 'ID of next modules')
756 size = bytereceived - SB_JVMMODULES_LIST_HEADER_SIZE - 4;
758 // Parse the modules list
759 mylist.Parse(Data(response.GetData() + SB_JVMPACKET_HEADER_SIZE + SB_JVMMODULES_LIST_HEADER_SIZE, size));
761 // Parse the ID of nextmodules
762 size_t id_offset = SB_JVMPACKET_HEADER_SIZE + SB_JVMMODULES_LIST_HEADER_SIZE + size;
763 const unsigned char *ptr = (response.GetData() + id_offset);
764 CheckSize(response, id_offset + sizeof(uint32_t));
765 uint32_t *poffset = (uint32_t *) ptr;
767 offset = be_btohl(*poffset);
768 } while (offset != 0); // When the offset != 0, there is some modules
773 // Get list of Java threads
775 void JVMDebug::GetThreadsList(JVMThreadsList &mylist)
777 uint32_t size = 0;
778 uint16_t expect = 0;
780 Data command(-1, 8), response;
781 JVMPacket packet(command, response);
783 // Send the command packet
784 packet.GetThreadsList();
786 m_socket->Packet(packet);
788 expect = packet.Size();
790 if (expect == 0)
791 return;
793 // Read the data stream
794 m_socket->Receive(response);
796 // MAKE_JVMPACKET(dpack, response); // unused
798 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
800 // Check the size read into the previous packet
801 if( expect != bytereceived ) {
802 ThrowJVMError(string("JVMDebug::GetThreadsList():") + _("byte count mismatch"), expect);
805 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMTHREADS_LIST_HEADER_SIZE);
807 // Number of threads entries in the list
808 // (Valid, but unused variable... disabled to stop compiler warnings)
809 // uint32_t count = be_btohl(dpack->u.threadslist.nbr);
811 // Size of threads list
812 // I remove the header of packet (contains the field 'number of threads')
813 size = bytereceived - SB_JVMTHREADS_LIST_HEADER_SIZE;
815 // Parse the threads list
816 mylist.Parse(Data(response.GetData() + SB_JVMPACKET_HEADER_SIZE + SB_JVMTHREADS_LIST_HEADER_SIZE, size));
818 // Complete threads list
819 JVMThreadsList::iterator b = mylist.begin();
820 for( ; b != mylist.end(); b++ ) {
821 JVMThreadsEntry entry = (*b);
823 // 1°/
824 // Send the command packet
825 packet.Unknown11(entry.Id);
827 m_socket->Packet(packet);
829 expect = packet.Size();
831 if (expect == 0)
832 return;
834 // Read the data stream
835 m_socket->Receive(response);
837 MAKE_JVMPACKET(dpack, response);
839 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
841 // Check the size read into the previous packet
842 if( expect != bytereceived ) {
843 ThrowJVMError(string("JVMDebug::GetThreadsList() (1):") + _("byte count mismatch"), expect);
846 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMUNKNOWN01_HEADER_SIZE);
848 // Save values
849 entry.Byte = dpack->u.unknown01.byte;
850 entry.Address = be_btohl(dpack->u.unknown01.address);
852 // 2°/
853 if (entry.Address != 0) {
854 // Send the command packet
855 packet.Unknown12(entry.Address);
857 m_socket->Packet(packet);
859 expect = packet.Size();
861 if (expect == 0)
862 return;
864 // Read the data stream
865 m_socket->Receive(response);
867 MAKE_JVMPACKET(dpack, response);
869 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
871 // Check the size read into the previous packet
872 if( expect != bytereceived ) {
873 ThrowJVMError(string("JVMDebug::GetThreadsList() (2):") + _("byte count mismatch"), expect);
877 // Save values
878 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.address));
879 entry.Unknown01 = be_btohl(dpack->u.address);
881 else
882 entry.Unknown01 = 0;
884 // 3°/
885 // Send the command packet
886 packet.Unknown13(entry.Id);
888 m_socket->Packet(packet);
890 expect = packet.Size();
892 if (expect == 0)
893 return;
895 // Read the data stream
896 m_socket->Receive(response);
898 dpack = (const Protocol::JVMPacket *) response.GetData();
900 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
902 // Check the size read into the previous packet
903 if( expect != bytereceived ) {
904 ThrowJVMError(string("JVMDebug::GetThreadsList() (3):") + _("byte count mismatch"), expect);
907 // Save values
908 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + sizeof(dpack->u.address));
909 entry.Unknown02 = be_btohl(dpack->u.address);
911 // 4°/
912 // Send the command packet
913 packet.Unknown14(entry.Id);
915 m_socket->Packet(packet);
917 expect = packet.Size();
919 if (expect == 0)
920 return;
922 // Read the data stream
923 m_socket->Receive(response);
925 dpack = (const Protocol::JVMPacket *) response.GetData();
927 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
929 // Check the size read into the previous packet
930 if( expect != bytereceived ) {
931 ThrowJVMError(string("JVMDebug::GetThreadsList() (4):") + _("byte count mismatch"), expect);
934 // Save values
935 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMUNKNOWN02_HEADER_SIZE);
936 entry.Unknown03 = be_btohl(dpack->u.unknown02.address1);
937 entry.Unknown04 = be_btohl(dpack->u.unknown02.address2);
939 // 5°/
940 // Send the command packet
941 packet.Unknown15(entry.Id);
943 m_socket->Packet(packet);
945 expect = packet.Size();
947 if (expect == 0)
948 return;
950 // Read the data stream
951 m_socket->Receive(response);
953 dpack = (const Protocol::JVMPacket *) response.GetData();
955 bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
957 // Check the size read into the previous packet
958 if( expect != bytereceived ) {
959 ThrowJVMError(string("JVMDebug::GetThreadsList() (5):") + _("byte count mismatch"), expect);
962 // Save values
963 CheckSize(response, SB_JVMPACKET_HEADER_SIZE + SB_JVMUNKNOWN02_HEADER_SIZE);
964 entry.Unknown05 = be_btohl(dpack->u.unknown02.address1);
965 entry.Unknown06 = be_btohl(dpack->u.unknown02.address2);
967 // Save...
968 (*b) = entry;
974 // Go
976 void JVMDebug::Go()
978 uint16_t expect = 0;
980 Data command(-1, 8), response;
981 JVMPacket packet(command, response);
983 // Send the command packet
984 packet.Go();
985 m_socket->Packet(packet);
986 expect = packet.Size();
988 while (expect == 0) {
989 m_socket->Receive(packet.GetReceive());
991 expect = packet.Size();
994 // Read the data stream
995 m_socket->Receive(response);
997 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
999 // Check the size read into the previous packet
1000 if( expect != bytereceived ) {
1001 ThrowJVMError(string("JVMDebug::Go():") + _("byte count mismatch"), expect);
1007 // Stop
1009 void JVMDebug::Stop()
1011 uint16_t expect = 0;
1013 Data command(-1, 8), response;
1014 JVMPacket packet(command, response);
1016 // Send the command packet
1017 packet.Stop();
1018 m_socket->Packet(packet);
1019 expect = packet.Size();
1021 while (expect == 0) {
1022 m_socket->Receive(packet.GetReceive());
1024 expect = packet.Size();
1027 // Read the data stream
1028 m_socket->Receive(response);
1030 size_t bytereceived = response.GetSize() - SB_JVMPACKET_HEADER_SIZE;
1032 // Check the size read into the previous packet
1033 if( expect != bytereceived ) {
1034 ThrowJVMError(string("JVMDebug::Stop():") + _("byte count mismatch"), expect);
1039 }} // namespace Barry::Mode